SED File processing tool Editor
Sed-i directly modify the contents of the file is not output to the terminal
Add and remove Vi:2,5del as a unit of behavior
NL (Show line number) passwd |sed ' 2,5d ' |head (tail)-N 10 No modification of source file
NL (Show line number) passwd |sed-i ' 2,5d ' |head (tail)-N 10 Modify source file
NL passwd |sed ' 2a drink tea ' |head-n 5|nl added below the second line
NL passwd |sed ' 2i drink tea ' |head-n 5|nl on the second row above
Replace
NL passwd |sed ' 2,5c No 2-5 number ' |head-n 5|nl
View Only
NL passwd |sed-n ' 2,5p ' uses-N to print only the contained rows without the-n will match and all the display
Search and display
NL passwd |sed-n '/root/p '
Delete
NL passwd |sed-n '/root/d '
Search and replace
Sed-i ' s/\.$/\/!/g ' 1.txt will end each line. Change for! Modify source file
Statistic line number
Sed-n "$=" If.txt
Wc-l If.txt | awk ' {print '} '
Sed-i ' 2s/^.*addr://' if.txt
Use of the SED command under Linux