1. Delete the first character of each line of the file: Sed-r ' s/^.//g ' passwd
2. Delete the second character of each line of the file: Sed-r ' s/^ (.) (.) /\2/g ' passwd
3. Delete the last character of each line of the file: Sed-r ' s/(.) $//g '
4. Delete the second last character of each line of the file: Sed-r ' s/(.) (.) $/\2/g ' passwd
5. Delete the second word in each line of the file: Sed-r ' s/^ ([A-z]) ([^0-9][^a-z]) (A-Z)/\1\2/g ' passwd
6. Delete the second-to-last word in each line of a file:
Sed-r ' s/([a-z]+) ([^0-9][^a-z]) ([a-z]+] $/\2\3/g ' passwd
7. Delete the last word in each line of the file: Sed-r ' s/([a-z]+) $ ' passwd
8, swaps the first and second characters of each line: Sed-r ' s/^ (.) (.) /\2\1/g ' passwd
9, swap the first character and the second word for each line:
Sed-r ' s/^ (.) ([a-z]+) ([^0-9][^a-z]+) ([a-z]+) ([^0-9][a-z])/\4\2\3\1\5/g ' passwd
10, swap the first word and the last word for each line:
Sed-r ' s/^ ([a-z0-9]+) ([^a-z0-9]+) (. +) ([^a-z0-9]+] ([a-z0-9]+)/\5\2\3\4\1/g ' passwd
11. Delete all the numbers in a file: Sed-r ' s/[0-9]//g ' passwd
12. Remove all spaces at the beginning of each line: Sed-r ' s/^//g ' passwd
13, replace any spaces that appear in the file with tabs.
14, enclose all capital letters in parentheses (): Sed-r ' s/[a-z]/(&)/g ' passwd
15, print 3 times per line: sed ' p;p ' passwd each p represents one print, and if no p is printed again, then no more than one P will print one more time
16, show only the first word of each line: Sed-r ' s/([^0-9a-z]+) (. +)//g ' passwd
17, print the first word and the third word of each line
18, use the command to get the format MM/YY/DD date format, combined with the pipeline, change it to MM;YY;DD format
Date "+%m/%y/%d" | Sed-r ' s/\/\-/g '
Linux Basic-sed+ Regular expressions