1 deletes the first line 2 . 3 Sed ' 1D ' test.txt pretend performed . 4 . 5 Sed -i ' 1D ' test.txt performed . 6 . 7 removed from the end of the second row to row . 8 . 9 Sed ' 2, D $ ' test.txt 10 . 11 Sed -i ' 2, D $ ' test.txt 12 is 13 is Sed -i ' 2,4D ' test.txt delete rows 2-4 14 15 remove beginning aaa line 16 . 17 Sed ' / ^ aaa / D 'test.txt 18 is . 19 Sed -i ' / ^ aaa / D ' test.txt 20 is 21 is the start of printing five lines from all lines to a starting aaa 22 is 23 is Sed -n ' 5, ^ aaa / P ' Test. txt #p: print print 24 25 a plurality of command execution sed 26 is 27 . 1 delete the first row to fifth row. 28 29 2 small letter into my mY. 30 31 is sed -e ' 1,5d ' -e ' S / My / MY / ' test.txt 32 33 is R & lt: aaa read inserted at the beginning of the following writing w 34 is 35 Sed '/ aaa / R & lt / etc / the passwd ' test.txt 36 37 [ live each write file contains aaa's 38 is 39 Sed ' / aaa / W / tmp / T2 / TXT ' test.txt 40 41 is to begin with the following additional line aaa append additional line 42 is 43 is Sed ' / ^ AAA / a \ BBBBBBB ' test.txt 44 is 45 specified row line append additional second line below line 46 is 47 Sed ' . 2A \ xxxxxxxxxxxxxx ' test.txt 48 49 operation on the next line matching lines Alternatively s 50 51 is Sed ' / AAA / n-{; s / iS / the iS /;} ' test.txt composite print only the first condition 52 is 53 is Sed ' / AAA / n-{; S / IS / the IS / G;} ' test.txt G can globally modify all of the conditions subject 54 is 55 to print odd-numbered lines -n Sed ' P; n- ' test.txt Sed - n- ' . 1 ~ 2P ' test.txt 56 is 57 is to print even-numbered lines -n Sed ' n-; P ' test.txt Sed -n ' 2 ~ 2P ' test.txt