Almost there! This will give you a grep line output, useful in editors like Vim to navigate the output file:
awk 'length > 80 {print FILENAME "(" FNR "): " $0}' *.cpp
Or specify the format you requested:
awk 'length > 80 {print FILENAME " line " FNR "\n\t" $0}' *.cpp
FILENAME and FNR (e.g. NR , but for this particular file) are special variables in awk .
Or you could use grep yourself, of course:
grep -n '^.\{80\}' *.cpp
Johnsyweb
source share