sed string processing tool

sed can not only analyze Standard input, but also replace, delete, add, and select specific rows of given data. The basic syntax is:

sed [-nefr] [动作]
  • -n Quiet mode, only output sed special processing lines
  • -e Edit directly in the action of sed
  • -f sed action is written in a file
  • -r sed The default regular expression becomes an extended regular expression
  • -i directly modify the content of the file to read instead of standard output

action:

[n1[,n2]]function

n1, n2 range of the number of lines of action, such as 10, 20 means from 10 to 20 lines. The function can be:

  • a Add the next line
  • c line replacement
  • d delete
  • i Peer insertion
  • p print
  • s rule replacement 1,20s/old/new/g

Guess you like

Origin blog.csdn.net/weixin_39258979/article/details/113832078