User Tools

Site Tools


bash:files:display_every_line_in_a_file_prefixed_with_a_line_number

BASH - Files - Display every line in a file prefixed with a line number

Print line numbers using a tab instead of a space.

awk '{print FNR "\t" $0}' filename

returns:

1	This would be the 1st line in the file...
2	This would be the 2nd line in the file...
3	This would be the 3rd line in the file...
4	...
bash/files/display_every_line_in_a_file_prefixed_with_a_line_number.txt · Last modified: 2022/06/13 12:10 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki