awk command for line numbers

Posted on 2009-02-17

The import formats for NumberPlanet include a position, which doesn't always exist. To get around this, here's an awk one-liner to add the line number as the postion field:

awk '{print $0NR}' infile.csv >outfile.csv

If you need to add a comma as well:

awk '{print $0","NR}' infile.csv >outfile.csv

Tags: awk csv