# tags: numlines, lines, numbers, pad, awk, code # # prepends uniformly padded line numbers to output to a width of # three zeros (999 max line number per file - adjust as needed) # Michael Sanders 2023 # https://busybox.neocities.org/notes/numlines.txt # # usage: awk -f numlines.txt FILE [FILE] # # example output... # # FILE: fubar.sh # # 001 #!/bin/sh # ... # 999 exit $? FNR == 1 { printf "\nFILE: %s\n\n", FILENAME } { printf "%03d %s\n", FNR, $0 } # eof