DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(gawk.info.gz) Single Character Fields

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