sed
One advantage sed has over grep is replacement.
Match the
specified line to filter out the lines containing the yang character in test.txt. (There is no space before p)
·
sed also supports symbols such as .* + in grep, but you need to add an escape character. If you don't want to add an escape character, you can add an r after -n.
With r
·
without r, use scramble
·
·
Print matching lines
Specify to print a certain line, and print the second line of test.txt.
·
Select a range and print out lines 2-5 of test.txt.
·
Print out the content after 20 lines of test.txt.
·
Print out the entire contents of test.txt.
·
List the first line of , and list the lines containing yang. (-e can then you do multiple operations in one command)
·
List the lines containing yang characters (including uppercase) in test.txt. (add a capital i before p, which means case insensitive)
·
·
Delete the specified line
Delete the first 20 lines of the test.txt file, the remaining line is line 21 (d is not really delete, just show the remaining lines.)
·
Really delete the first 20 lines of the test.txt file, (-i really delete the file content)
·
Delete by keyword, really delete the line containing yang in the test.txt file
Replace Replace 1 - yang
in the last line is shuai. (and replace a writing in vim)
·
Replace 1- ro, roo, rooo.. in the last line with r. (Character names can use regular expressions)
·
In the first ten lines of test.txt, the lines separated by: , and the positions of the first and last paragraphs are exchanged.
·
If there are special symbols in the characters to be replaced, you need to use escape characters, or use other separators (using @ or #).
·
Delete the letters in the first ten lines of the file. (Leave a space after the second slash to delete) The content of square brackets can be modified to numbers, single letters
·
Add aaa: to the first ten lines of the file. (The content enclosed in parentheses can be represented by 1 or &)
·