Basically, you should set FS before it may be called upon to split $0 into fields. Once awk encounters a `{', it is probably too late. Some awk implementations set the fields at the beginning of the block, and don't re-parse just because you changed FS. To get the desired behavior, you must set FS _before_ reading in a line. e.g., {{{ awk BEGIN { FS=":" } { print $1 } }}} e.g., {{{ awk -F: '{ print $1 }' }}} if you run code like this {{{ awk { FS=":"; print $1 } }}} on this data: {{{ first:second:third but not last:fourth First:Second:Third But Not Last:Fourth FIRST:SECOND:THIRD BUT NOT LAST:FOURTH }}} you may get either: {{{ this: or this: ---- ------- first first:second:third First First FIRST FIRST }}} perhaps more surprisingly, code like {{{ awk { FS=":"; } { print $1; } }}} will also behave in the same way.
Summary:
This change is a minor edit.
Username: