Add numbers to the beginning of every line in a file

后端 未结 7 1672
暗喜
暗喜 2020-12-01 02:44

How can I add numbers to the beginning of every line in a file?

E.g.:

This is
the text
from the file.

Becomes:

000000001 This is
000         


        
7条回答
  •  失恋的感觉
    2020-12-01 03:02

    Easiest, simplest option is

    awk '{print NR,$0}' file
    

    See comment above on why nl isn't really the best option.

提交回复
热议问题