Is there a way for awk to change FS *before* it processes a record?
In the following example, I want awk to change FS whenever the
beginning of the record matches certain characters:
$ cat file1
#field1,field2,field3
#field1,field2,field3,field4
#field1,field2
@[EMAIL PROTECTED]
awk '/^#/{FS=",";print $1}/^@[EMAIL PROTECTED]
";";print $1}' file1
#field1,field2,field3
#field1
#field1
@[EMAIL PROTECTED]
you can see FS does change, but not until after the first matching
record has been processed using the previous FS.


|