The following commands yield the same answer:
tail -n 1 ~/watchip.sh.csv | awk 'BEGIN { FS = "," } ; { print $1 }' tail -n 1 ~/watchip.sh.csv | awk '{ FS = "," } ; { print $1 }' EDIT: Since posting this question, I've learned my assertion that the two commands above yield the same answer is NOT true. At least not in general. And so it seems that the command above is an example of when a
BEGINstatement is required. Apologies for the confusion.
I'm not an experienced awk user, but trying to get a better handle on it through usage & reading the documentation. But everything I've read on BEGIN and END is fuzzy (makes little sense to me). Perhaps this is because I have only used awk in very limited situations.
Can someone explain briefly when a BEGIN statement would be required in awk?