grep -n ...
prefixes each line with its line number. But the formatting can make the output hard for human interpretation:
$ grep -n hello hello.txt
1:hello my dear
5:hello in another line
17:this is a hello in a two-digits line number
20:another hello in the two-digits line realm
3838813:it's a long file and here comes one last hello
Is there a way to have grep
show line numbers in a padded way, for instance with leading zeros or leading spaces?
Example:
$ grep -n -$MAGIC hello hello.txt
1:hello my dear
5:hello in another line
17:this is a hello in a two-digits line number
20:another hello in the two-digits line realm
3838813:it's a long file and here comes one last hello