sed [-n] [-e] 'command(s)' files
sed [-n] -f scriptfile files
可以写在 文件中使用 sed -f scriptfile files
这样的格式调用
在scriptfile中最后一个命令 写一行 类似于执行 sed -e 'commad1' -e 'commad2' files
或者 sed 'commad1;commad2' files
这一接使用到的选项有
选项 | 意义 |
---|---|
-n | Default printing of pattern buffer 默认情况下会在每行将pattern buffer 的内容打印出来 这个选项抑制打印 |
-f | 执行文件 |
-e | execute执行多个命令 |
GNU的选项
选项 | 意思 |
---|---|
-n, –quiet, –silent: | Same as standard -n option. |
-e script, –expression=script: | Same as standard -e option. |
-f script-file, –file=script-file: | Same as standard -f option. |
–follow-symlinks: | If this option is provided, the SED follows symbolic links while editing files in place. 跟随链接到具体文件 |
-i[SUFFIX], –in-place[=SUFFIX]: | This option is used to edit file in place. If suffix is provided, it takes a backup of the original file, otherwise it overwrites the original file. 这个用来编辑文件 用法 sed -i 'back' 'commad1;command2' files 这个命令的意思是将 files 进行修改 并且 修改之前 会创建一个.back 的备份文件 |
-l N, –line-lenght=N: | This option sets the line length for l command to N characters. 规定每行长度是 N |
–posix: | This option disables all GNU extensions. 去除掉所有的GNU extensions |
-r, –regexp-extended: | This option allows to use extended regular expressions rather than basic regular expressions.加强版正则 有的时候会是-E |
-u, –unbuffered: | When this option is provided, the SED loads minimal amount of data from the input files and flushes the output buffers more often. It is useful for editing the output of “tail -f” when you do not want to wait for the output. |
-z, –null-data: | By default, the SED separates each line by a new-line character. If NULL-data option is provided, it separates the lines by NULL characters. 使用null 字符 区分行 |