1 | [address]command [text] |
1 2 | ( echo 'OPERATION'; echo 'OPERATION'; ... echo 'wq' ) | ed -s FILENAME |
1 2 3 4 5 6 7 | $ cat file This is the end. $ (echo '0a'; echo 'This is the beginning.'; echo '.'; echo 'wq') | ed -s file $ cat file This is the beginning. This is the end. $ |
1 2 3 4 5 6 7 8 9 10 11 | $ cat file This is the end. $ ed -s file > 0a > This is the beginning. > . > wq $ cat file This is the beginning. This is the end. $ |
1 | $ (echo '0r headnotes'; echo 'wq') | ed file |
1 2 3 4 5 6 7 | $ ( echo '/begin/a'; echo 'This is the middle.'; \ > echo '.'; echo 'wq') | ed -s file $ cat file This is the beginning. This is the middle. This is the end. $ |
1 2 3 4 5 6 7 8 9 10 11 12 13 | $ for i in *.xml > { ed -s $i << EOF > /<records>/a \ > <record> \ > <name>johnnycomelately</name> \ > <step>10</step> \ > <dur>4</dur> \ > </record>\ > . > wq > EOF > } $ |
1 | $ (echo '/END OF PART I/r footnotes.txt'; echo 'wq') | ed file |
1 | $ ( echo '/FOOTNOTES/,$/d'; echo 'wq' ) | ed -s file |
1 | $ ( echo '1,/\.\.\./d'; echo 'wq' ) | ed -s file |
1 2 3 4 5 6 7 8 9 10 | $ cat -vet input.txt This line has trailing blanks. $ This line does not.$ $ (echo ',s/ *$//'; echo 'wq') | ed -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 |