Print all Fields with AWK separated by OFS

This is a variation on the first style: echo “1 2 3 4″ | gawk ‘BEGIN { OFS=” 🙁 “}; {$1=$1; print $0}’ Results: 1 🙁 2 🙁 3 🙁 4 Explanation: the $1=$1 is to rebuild the record, using the current OFS (you can also see http://www.gnu.org/software/gawk/manual/gawk.html#Changing-Fields) Update: (suggested by @EdMorton and @steve) This … Read more

ignorecase in AWK

Add IGNORECASE = 1; to the beginning of your awk command like so: bash-3.2$ echo “Create” | awk ‘/^create/;’ bash-3.2$ echo “Create” | awk ‘IGNORECASE = 1;/^create/;’ Create

Casting to int in awk

Most new awks have an int() function. But the method for casting documented in ‘The Awk Programming Language’ is shown as you do it, by using numericValue and +0. I don’t have the book handy, but I think you can also cast for float value by using +0.0. I hope this helps.

How to run a .awk file?

The file you give is a shell script, not an awk program. So, try sh my.awk. If you want to use awk -f my.awk life.csv > life_out.cs, then remove awk -F , ‘ and the last line from the file and add FS=”,” in BEGIN.