用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.






本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2013/01/09/2853406.html,如需转载请自行联系原作者

目录
热门文章
最新文章