Using Awk to add a column to a file
I had a need to add an extra column of numbers (all the same) to dataset the other day… so simple todo with an awk script
printf(“%10d %10d %6dn”, $1, $2 ,”10″);
Just save the above input like something like add_column.awk, make it executable (something like chmod 700 add_column.awk) and run it (the above just adds “10” to each line and is simple to change to a variable or some other string):
add_column.awk yourinputfile > youroutputfile
and job done.