Search code examples
shellfileunixline

How to add "/1/" as a line number in a txt file?


In Unix I want to add slash before and after the line number in a .txt file

this command only shows the line numbers cat -n txt.file

this:

Tony
Alpha
Bravo

to this:

/1/ Tony
/2/ Alpha
/3/ Bravo

Solution

  • awk '{print "/" FNR "/ " $0}' file