In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Today, the editor will bring you an article about the use of Linux text processing tools. The editor thinks it is very practical, so I will share it for you as a reference. Let's follow the editor and have a look.
1 count the number of users in the / etc/passwd file whose default shell is not / sbin/nologin, and display all the users
Grep is a text tool that is processed by matching text on one line; using the grep command to display mismatched lines with the help of the-v parameter; getent passwd | grep-Ev / sbin/nologin$
2 find out the user name, UID and shell type of the maximum UID of the user
Sort is used for sorting, adding specific parameters can be sorted according to different needs; head users take the first few rows; cut is used to take specific columns; sort-K3-t ":"-rn uses colons as delimiters, and the third column is sorted in reverse numerical order; cut-d ":"-F1, 3primes 7, with colons as separators, take columns 1,3 and 7.
3 count the number of connections to each remote host IP that is currently connected to this machine, and sort them from largest to smallest.
Ss can check the number of local connections, cooperate with grep to filter sessions that have established connections, compress through tr -, intercept the corresponding columns through cut, sort by sort, and perform de-duplication statistics through uniq.
4 write script createuser.sh to achieve the following functions: use a user name as a parameter, if the user of the specified parameter exists, show its existence, otherwise add it; display information such as the id number of the added user
Read variables through read command; judge by test; select conditions by if; specify exit code by exit
5 write a script that generates the basic format of the script, including author, contact information, version, time, description, etc.
When the user adds a directory to edit the contents of vim.rc, the corresponding information can be added when the .sh script file is created.
After reading the above, have you mastered the use of Linux text processing tools? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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: 0
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.