Sed command echo command

echo “nihao” >> /root/guo/txt to add a good addition to txt Replace writeecho “nihao” > /root/guo/txt 

Sed is a good file processing tool, which in itself is a conduit command, mainly processed by the unit of conduct, allowing for the replacement, deletion, addition, selection and so on of the data line. [-nefri] `command ‘Input text common options: -n use quiet mode. In the general sed usage, all information from STDIN is normally listed on screens. But if -n parameters are added, only the line (or action) that has been handled by sed will be listed. e) Directly edits the actions of sed in command row mode; f) write the actions directly to a file, and then write the actions of sed in a new string (the current row) ⁇ c} replaces the actions in file name; r ⁇ sed supports extended formal expressions, these words can replace n1, i) read the contents of files directly instead of being exported from screen. The usual commands: a add a, a can be followed by a string which appears in a new row, c) replaces those words later, and these words can replace n), which appear before {1), d} and then delete the next line, so it appears that the last word is deleted (restow line) and then the next one is deleted (d) is deleted. # sed ‘d’ ab # # sed ‘$d’ ab # delete the last line [root@localhost rubby] # sed ‘od’ ab # [Root@localhostruby] # sed-n ‘$p’ab # displays the last line [root@localhost ruby] # sed-n ‘1, 2p’ab # shows the first to the second line [root@localhost ruby] # sed-n ‘2 ‘ab # displays the second to the last line # use modes for queries [root@localhost ruby] # sed-n ‘/ruby/p’ab # Query includes key words in all lines [root@localhost ruby] # sed-n ‘/$/p’ab # includes key words in all rows, using an a backlash \special meaning # [Root@localhost ruby] # sed ‘1a drink tea’ ab # add string “drink tea” after first line! [Root@localhostruby] # sed ‘1c Hi’ab #end [root@localhost rule] # sed ‘1, 2c Hi’ ab # First to second rows instead of Hi Hi End # Format: sed ‘s/new string/g’ (replaced string can be regular expression) # root -n ‘ / rocalhost ⁇ sed ‘s/ruby/bird/g’ # replaces bridroot _localhost # sed ‘/p ‘ ab ‘ sed/ruby/g # delete [Root@localhost ruby] #ed-i ‘$a by’ab #


sed-i ‘ 3s/aaa/fff/’file — indicating the third line of the file for file, replacing aaa in it with fff sed -i ‘ /xxx/s/aaaa/fff/g ‘ file — indicating that for document, the row containing xx is identified and that aaa in it is replaced by fff sed -i ‘ 1s/[#]/fff/gp ‘ file — indicating that the number # or * is replaced by fff sed -i ‘s/… …/ …/ …/ g ‘ file name is replaced with …… …ed ‘ 1 c Hi’ab and the first line of the current folder ab file is modified to have the path \ added to the Hi sed configuration file as follows: Transfer.

sed -i ‘108c Exec=\/usr\/bin\/google-chrome-stable %U- -no-sandbox’ /usr/share/applications/google-chrome.desktop

未经允许不得转载:萌萌Apprentissage » Sed command echo command

Like (0) 打赏

Comments 0

Protected with IP Blacklist CloudIP Blacklist Cloud
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

//下一个脚本特效
//下一个脚本