Home > front end >  How to print the content of file along with line number without using cat -b or cat -n option
How to print the content of file along with line number without using cat -b or cat -n option

Time:12-23

Can I display content of a file along with line number without using cat -b or cat -n option?

I am using

cat -s -n fileName

And got the below output:

 1  Hi
 2  Hello

But whether is it possible to make this without cat -b or cat -n option?

CodePudding user response:

Such as nl command.

nl -b a fileName

CodePudding user response:

You can use awk command

awk '{print NR  $0}' fileName
  • Related