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

Detailed explanation of the use of Linux text processing tools

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1. Count the number of users whose default shell is not / sbin/nologin in the / etc/passwd file, and display all the users.

Grep is a text tool that is processed by matching text on one line

Display lines that do not match with the-v parameter through the grep command

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 requirements.

Head users take the first few lines of

Cut is used to fetch specific columns

Sort-K3-t ":"-rn uses colons as delimiters and sorts numbers in reverse order with the third column

Cut-d ":"-F1 Magi 3JE7 take column 1, column 3 with colons as separators.

3. Count the number of connections to each remote host IP that is currently connected to this machine, and sort them from large to small.

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 a 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 the read command

Judge by test

Condition selection through if

Specify the exit code through 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.

So far, this is the end of this article on the detailed explanation of the use of Linux text processing tools. For more information about the simple use of Linux text processing tools, please search for previous articles or continue to browse the relevant articles below. I hope you will support me in the future!

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.

Share To

Servers

Wechat

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

12
Report