使用参数:
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...
-n, --quiet, --silent suppress automatic printing of pattern space -e script, --script add the script to the commands to be executed -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) -c, --copy use copy instead of rename when shuffling files in -i mode (avoids change of input file ownership) -l N, --line-length=N specify the desired line-wrap length for the `l' command --posix disable all GNU extensions. -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 --version output version information and exitIf no -e, --expression, -f, or --file option is given, then the firstnon-option argument is taken as the sed script to interpret. Allremaining arguments are names of input files; if no input files arespecified, then the standard input is read.将错误报告通过电子邮件发送到:bonzini@gnu.org .请务必将单词“sed”放在“Subject:”域的某处。添加行
sed -i 'aaaa' test.txt
发现所有的行都加上了aaaa
删除行
sed -i '/aaaa/,+d' test.txt
删除73和74行内容(源文件改变)
sed -i '73,74d' modules.conf
删除73和74行内容(源文件不变)
sed '73,74d' modules.conf
在73行插入include "conf.d/proxy.conf"内容(源文件改变)
sed -i '73a include "conf.d/proxy.conf"' modules.conf
在73行插入include "conf.d/proxy.conf"内容(源文件不变)
sed -i '73a include "conf.d/proxy.conf"' modules.conf
替换指定行内容
sed -e '1,10s/enchantment/entrapment/g' myfile2.txt