Linux sed的学习

sed (意为流编辑器,源自英语“stream editor”的缩写)是Unix常见的命令行程序。sed 用来把文档或字符串里面的文字经过一系列编辑命令转换为另一种格式输出。sed 通常用来匹配一个或多个正则表达式的文本进行处理。 sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed's ability to filter text in a pipeline which particularly distinguishes it from other types of editors.

2009-06-10 12:28:32

sed的介绍:
http://zh.wikipedia.org/wiki/Sed
http://www.gnu.org/software/sed/manual/sed.html

使用sed:
Sed命令列可分成编辑指令与文档部份。其中,编辑指令负责控制所有的编辑工作,文档表示所处理的文件。编辑指令均由地址 (address) 与函数 (function) 两部份组成,其中,在执行时,sed利用它的地址参数来决定编辑的对象的位置,而用它的函数参数编辑。
sed [OPTION]... {script-only-if-no-other-script} [input-file]...

例子
sed -e '1,3d' 1.txt
-e的意思为执行一个编辑指令
1,3d意思为删除1-3行 1,3为位置,d为删除命令

-e script, --expression=script add the script to the commands to be executed

徜徉于这片废土的我们.....应当去哪里追寻更好的自己?