Setting the field seperator in awk(1)

Arnold Robbins arnold at audiofax.com
Sat Oct 20 03:33:20 AEST 1990


In article <2453 at linac.fnal.gov> palkovic at linac.fnal.gov (John A. Palkovic) writes:
>I would like to set the field separator in awk(1) so that in addition
>to the default separator I could include a comma with white space,
>as well as the default case, which is just white space.

You have to have either nawk or gawk for this; old awk won't work.  Assuming
you have nawk or gawk, all you need is

	FS = "[ \t,]+"

This says that fields are separated by runs of one or more blanks, tabs,
or commas.  The (current) AWK language says that if FS == " ", it's a
special case, and is treated as if FS were "[ \t]+", i.e. runs of blanks
and/or tabs.
-- 
Arnold Robbins				AudioFAX, Inc. | Laundry increases
2000 Powers Ferry Road, #200 / Marietta, GA. 30067     | exponentially in the
INTERNET: arnold at audiofax.com Phone:   +1 404 933 7612 | number of children.
UUCP:	  emory!audfax!arnold Fax-box: +1 404 618 4581 |   -- Miriam Robbins



More information about the Comp.unix.questions mailing list