Using awk
to parse a string on the command line character by character:
echo "foo" | awk 'BEGIN { FS = "" }{ for (n=1; n<=NF; n++ ) print $n }'
works fine. We can also set the value of FS on the command line. However this:
echo "foo" | awk -F '' '{ for (n=1; n<=NF; n++ ) print $n }'
yields the following error message:
awk: field separator FS is empty
Why don't both methods return identical results?
Important: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)