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

What is the function of AWK in LINUX

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about the function of AWK in LINUX, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article, without saying much, follow the editor to have a look.

Main functions: row fetch, column fetch, data statistics

Basic format:

Awk-F 'split character' {print $1} 'filename

2the schematic diagram of dint awk logic:

Content in the awk-BEGIN module (BEGIN'{print $1}')

Read the first line of the text (read by line)-if the output result is not satisfied, the next line continues to read until the entire text is finished.

Awk-F 'split character' {print $0} 'file name indicates that full column information is displayed

$0 represents a scalar, meaning all

Awk can also be used to find

Awk'/ character / 'file name

3. Match plus processing action

Awk also supports regularities

The difference between NF and NR (NF stores the number of columns, NR stores the number of rows)

Awk-favored etc/passwd'$1mm / ^ root/' / match ~ indicates a match

Awk-favored NF~/bash$/''$NF~/bash$/' / etc/passwd

The value of $NF refers to the last column.

The use of operators that compare sizes and equals in awk

4, example: how many ordinary users are there at present?

Statistics of disk partition usage?

Df | awk NR==2 | awk'$31000000 {print $4} 'matches the third column in the information ending with / (used has been used) and outputs its fourth column if it is greater than 1000000 (remaining available available)

5Jing awk filter ip address

6Jing awk batch create users, use dynamic passwords and save

These are the functions of AWK in LINUX. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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