Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Text processing 3 swordsman sed command

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 254

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report