[PLUG] awk syntax

Rich Shepard rshepard at appl-ecosys.com
Thu May 24 18:04:53 UTC 2012


   I'm re-reading the ORA 'sed & awk' 2nd edition because I need to modify
data files (>130K lines in one and >45K lines in another). Should be a
simple script but I'm getting a syntax error trying to define the OFS.

   Here's a line of the data file:
'D-1'|'2007-12-12'|'Ag'|0.000|

   Since fields in the data file are delineated with '|'. I define FS = '|'
in the BEGIN section, but awk doesn't like me to also define OFS there:

awk: ./add-non-detect.awk:7: BEGIN { FS = "|" OFS = "|" }
awk: ./add-non-detect.awk:7:                      ^ syntax error

   There's no explicit example in the book, only statements that the default
output field separator is a space, and that's applied by putting a comma
after the field variable. What have I missed?

Rich







More information about the PLUG mailing list