- 论坛徽章:
- 1
|
shell基础十二篇
看完,对什么时候使用什么选项还是有些糊涂
man sed
- -n, --quiet, --silent
-
- suppress automatic printing of pattern space
- 前面举过例子:
- [sam@Linux_chenwy sam]$ sed -n '2p' quote.txt
- It was an evening of splendid music and company.
- 如果没有-n,就把其它的都打印出来了
复制代码
- -e script, --expression=script
- add the script to the commands to be executed
- 呵,跟多个表达式啊
- [sam@Linux_chenwy sam]$ sed -n -e '/music/p' -e '/music/=' quote.txt
- It was an evening of splendid music and company.
- 2
复制代码
- -f script-file, --file=script-file
-
- add the contents of script-file to the commands to be executed
- 脚本文件
复制代码
- -i[suffix], --in-place[=suffix]
-
- edit files in place (makes backup if extension supplied)
- 寂寞烈火说过:是直接更更改原文件,不过最好用重定向
复制代码
-l N, --line-length=N
specify the desired line-wrap length for the `l' command
-r, --regexp-extended
use extended regular expressions in the script.
-s, --separate
consider files as separate rather than as a single continuous
long stream.
-u, --unbuffered
load minimal amounts of data from the input files and flush the
output buffers more often
--help display this help and exit
-V, --version
output version information and exit
If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret. All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.
E-mail bug reports to: bonzini@gnu.org . Be sure to include the word
``sed'' somewhere in the ``Subject:'' field. |
|