Dup Ver Goto 📝

Basics

PT2/lang/awk does not exist
To
16 lines, 91 words, 523 chars Page 'Basics' does not exist.

$0 $1 etc

$0 is the whole line, $1 is the first column, $2 the second, etc.

Shift

There is no shift in awk. So you need to be a little creative.

The example here is to turn a two column, whitespace delimited table into a markdown table.

awk '{ printf("| %s | ",$1); for(i=2;i<=NF;i++) printf("%s ",$i); print " |"; }'

though this does not respect whitespace. In the case of the above, sed does a better job:

sed -e 's/^\s*\(\w*\)\s\s*\(.*\)$/| \1 | \2 |/'