Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!pacbell.com!pacbell!rtech!wrs!yuba!roger From: roger@yuba.wrs.com (Roger Rohrbach) Newsgroups: comp.unix.questions Subject: Re: -F option for awk Keywords: awk field-separator Message-ID: <1190@wrs.wrs.com> Date: 13 Aug 90 21:41:03 GMT References: <491@llnl.LLNL.GOV> Sender: news@wrs.wrs.com Lines: 36 rjshaw@ramius.ocf.llnl.gov (Robert Shaw) writes: >When awk'ing something like a passwd file, where the reasonable choice >of field separator is something other than whitespace, how do you >let a line simply fall through and be printed unchanged? >print; or print $0; don't do the right thing because the lines come >out with spaces as the field separators instead of the character given >to the -F option. I don't know what version of awk you are using; both the old and GNU versions of awk print the input line unchanged unless you explicitly reset the OFS (output field separator) variable. I.e, awk -F: '{ print }' /etc/passwd prints /etc/passwd unchanged. As a matter of fact, if you want the behavior you claim to be experiencing, you not only have to set OFS, but you have to mess with one of the fields in order to get awk to recompute $0, i.e., awk -F: ' BEGIN { OFS = " " } { $1 = $1 # recompute $0 print }' /etc/passwd produces the behavior you describe. Perhaps "new awk" behaves differently; in that case, try setting OFS to FS and use this trick. Roger Rohrbach sun!wrs!roger roger@wrs.com - Eddie sez: ----------------------------------------------- (c) 1986, 1990 -. | {o >o | | \ -) I'm lurching between the aesthetic sublime and the quotidian grime. |