用sed 给文本文件加行号
2013-01-09 17:56
106 查看
看例子:
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.
[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.
相关文章推荐
- 删除文本文件行号的小方法(shell,sed)
- 搜索当前目录下所有文件包含某关键词的文本/文件名/行号
- linu sed 命令 打印匹配行 和匹配行号 ,打印文件中间几行
- sed直接替换文本文件(sed与awk是正则表达的俩大神器)
- c程序设计语言_习题7-6_对比两个输入文本文件_输出它们不同的第一行_并且要记录行号
- vim或sed删除文本文件中所有的中文字符
- Java基础之IO流,按指定行号范围读取文本文件内容,带行业、带缓冲
- 自定义字符输入流的包装类,通过这个包装类对底层字符输入流进行包装,让程序通过这个包装类读取某个文本文件(例如,一个java源文件)时,能够在读取的每行前面都加上有行号和冒号。
- 第13周-项目1-小玩文件-将文本文件中的所有行加上行号后写到新文件中
- centos 正则,grep,egrep,流式编辑器 sed,awk -F 多个分隔符 通配符 特殊符号. * + ? 总结 问加星 cat -n nl 输出文件内容并加上行号 alias放~/.bash_profile 2015-4-10 第十三节课
- 补:小玩文件2--将文本文件中的所有行加上行号后写到新文件中
- 如何替换某文件中的所有的特定字符?---linux sed命令(文本编辑命令) (转载)
- 如何替换某文件中的所有的特定字符?---linux sed命令(文本编辑命令)
- sed 查询文本, 输出带有行号
- shell sed 在文件第一行后插入文本
- 通过sed在文件指定行号后添加一行
- C#写入TXT文本文件
- linux shell 用sed命令在文本的行尾或行首添加字符
- sed实现直接修改文件内容
- Java操作读取写入文本TXT及XML文件内容