Nl

Add line numbers to a file (Four digits, leading zeros, separated by a colon):

nl -i1 -s': ' -nrz -w4 cotus.txt

awk '{printf"%04d: ",NR;print}' cotus.txt

Oh wait, you don’t want to count the blank lines?

awk '/[^ ]/{printf"%04d: ",++n}{print}' cotus.txt

Oh wait, you only want the first 30 lines?

awk '/[^ ]/{printf"%04d: ",++n}{print}NR==30{exit}' cotus.txt

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s