Awk does not work as expected with double quotes
March 22, 2007 – 2:54 amOf course, I felt like an idiot after being completely confused by this for about half an hour.
Consider this:
awk "{print $1}" somefile.txt
This does not work as I had expected. The reason is because the $1 is evaluated within double quotes, (not single quotes). Yes, it’s a rookie mistake, but I never claimed to be the awk master.
So, always write:
awk '{print $1}' somefile.txt
and you will avoid a headache.


