Text processing 3 swordsman sed command
1. Delete the white space characters at the beginning of all lines that begin with white space in the centos7 system / etc/grub2.cfg file
2. Delete all # and white space characters starting with # followed by at least one white space character in the / etc/fstab file
3. Add # at the beginning of each line in the centos6 system / root/install.log
4. Add a # sign at the beginning of a line that does not begin with # in the / etc/fstab file
5. Process the / etc/fstab path, and use the sed command to fetch its directory name and base name
6. Use sed to retrieve the IPv4 address of the local machine in the ifconfig command
7. Statistics of all rpm files under the Package directory in the centos installation CD. Separate the number of repeats of the penultimate field
8. Count and sort the number of occurrences of each word in the / etc/init.d/functions file (implemented by grep and sed respectively)
The results are so different.
Grep-o "[[: alpha:]]\ +" / etc/init.d/functions | sort | uniq-c | sort-nr
Sed-nre's / [^ [: alpha:]] + /\ nGPP'/ etc/init.d/functions | sort | uniq-c | sort-n
9. Merge the n and next1 lines of the text file into one line, where n is an odd line