用sed 给文本文件加行号

看例子:

[root@localhost tmp]# sed '=' test.txt
1
tsttst tsttsttst
2
west gao
3
west abces
[root@localhost tmp]# sed = test.txt | sed 'N;s/\n/\t/'
1       tsttst tsttsttst
2       west gao
3       west abces
[root@localhost tmp]# 

N的解释:

N:Add a newline to the pattern space, then append the next line of input to the pattern space. If there is no more input then sed exits without processing any more commands.

posted @ 2013-01-09 17:56  健哥的数据花园  阅读(5769)  评论(0编辑  收藏  举报