1 | sed -i script filespec |
1 | sed script file > newfile; mv newfile file |
1 | for i in *; { sed script $i > $i.new; mv $i.new $i; } |
1 | $ sed -i 's/old/new/' file |
1 | $ sed -i 's/Esclipse/Eclipse/g' *.xml |
1 2 3 4 5 6 7 8 | $ cat file This is the beginning. This is the middle. This is the end. $ sed 's/[Tt]h/[Tt]h/g' file [Tt]his is [Tt]he beginning. [Tt]his is [Tt]he middle. [Tt]his is [Tt]he end. |
1 | $ sed -i 's,/usr/local/websphere,/usr/websphere,' file |
1 | $ sed -i 's/.*pattern.*/LINE DELETED/' file |
1 2 3 4 5 6 7 8 | $ cat file This is the beginning. This is the middle. This is the end. $ sed 's/[Tt]h/>&</g' file >Th<is is >th<e beginning. >Th<is is >th<e middle. >Th<is is >th<e end. |
1 | $ sed -i '/pattern/a text' file |
1 2 3 4 | $ sed 's/^/> /' input.txt > This line has trailing blanks. > This line does not. $ |
1 2 3 4 | $ sed 's/$/$/' file This line has trailing blanks. $ This line does not.$ $ |
1 | $ sed -i 1d file |
1 | $ sed -i 1,10d file |
1 | $ sed -i '/BEGIN QUOTE/,/END QUOTE/d' file |
1 | $ sed -i '/<record>/,/<\/record>/d' *.xml |
1 | $ sed -i '/^> /d' file |
1 | $ sed -i /^$/d file |
1 | $ sed -i '$d' file |
1 2 3 4 5 6 7 8 9 10 | $ cat -vet input.txt This line has trailing blanks. $ This line does not.$ $ sed -i 's/ *$//' input.txt $ cat -vet input.txt This line has trailing blanks.$ This line does not.$ $ |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |