gawk: Single Character Fields

1 
1 4.5.3 Making Each Character a Separate Field
1 --------------------------------------------
1 
1 There are times when you may want to examine each character of a record
1 separately.  This can be done in 'gawk' by simply assigning the null
1 string ('""') to 'FS'.  (c.e.)  In this case, each individual character
1 in the record becomes a separate field.  For example:
1 
1      $ echo a b | gawk 'BEGIN { FS = "" }
1      >                  {
1      >                      for (i = 1; i <= NF; i = i + 1)
1      >                          print "Field", i, "is", $i
1      >                  }'
1      -| Field 1 is a
1      -| Field 2 is
1      -| Field 3 is b
1 
1    Traditionally, the behavior of 'FS' equal to '""' was not defined.
1 In this case, most versions of Unix 'awk' simply treat the entire record
11 as only having one field.  (d.c.)  In compatibility mode (⇒
 Options), if 'FS' is the null string, then 'gawk' also behaves this
1 way.
1