您的位置:首页 > 其它

用sed 给文本文件加行号

2013-01-09 17:56 106 查看
看例子:

[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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐