有a.txt内容如下:- 1:When I was a little girl, I found love in a box all because of a class assignment.
- 2:On a Friday night I made an announcement at the dinner table.
- 3:The words bubbled out in a torrent of excitement I could no longer contain.
- 4:“My teacher said we have to bring a box for our valentines on Monday.
- 5:But it has to be a special box, all decorated.”
- 6:Mother said, “We’ll see,” and she continued eating.
- 7:I wilted faster than a flower with no water.
- 8:What did “We’ll see” mean?
- 9:I had to have that box or there would be no valentines for me.
- 10:My second grade Valentine’s Day would be a disaster.
复制代码 41、根据用户输入的内容"pause"来取代第5-8行所有的内容(非每行)复制代码 c开关是sed中用用户输入内容来取代原本内容的,其后紧跟"\",用这种方法同样可以将指定行替换为空行(并不是严格意义上的空行,至少有一个空格),如:sed "9c\ " a.txt。
42、根据用户输入的内容"pause"来取代文本所有的行复制代码 1,$表示的是从第一行到最后一行
43、删除文本所有行首的四个字符复制代码 其实就是将行首的四个字符替换为空。
44、删除文本所有行尾的四个字符复制代码
45、将文本行右移四个字符位复制代码
即将行首(实际是一个空字符)替换为四个空格,也就在每行前加入了四个空格而将行右移了四位。
[ 本帖最后由 batman 于 2008-9-26 13:29 编辑 ] |