sed using the shell finishing

1. sed will read data from the file line by line, to the screen again after data processing, and then processing the next line.

  sed '4d' file.txt # delete files in line 4

  sed '2,6d' file.txt # delete a file in rows 2-6

 

2. sed in regular use:

  sed with the grep command, by default it does not support extended metacharacters solution:

  1. The expansion element becomes substantially slash characters plus the corresponding character element.

  2. sed -r -r parameter is added, supports extended meta-characters.

 

3. sed use the Find and Replace:

  Alternative uses:

  1. sed -r 's / xx / XX /' # is replaced xx XX, the replacement of only one of each row

  2. sed -r 's / xx / XX / g' # replace a line of all xx XX

  3. sed -r 's / xx / XX / gi' # ignores row matches the case of replacement content

  Find the use of:

  1. sed -r '/ xx / d' # Do not use Find s, find and delete xx

Guess you like

Origin www.cnblogs.com/quzq/p/12121680.html