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 use of the awk command in linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article shows you the use of the awk command in linux, which is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Awk command syntax

Awk [options] Pattern {Action} file

Df | head-5 | awk'{print $1, $5}'

Options and Pattern are not used in this example, indicating the output of the first and fifth columns, where $1 represents the first column, $0 represents the positive row, and $NF represents the last column. (note: $NF is different from NF. NF indicates how many columns there are in the row.)

BEGIN, END: actions taken before and after data processing

Options

-F specifies the delimiter ()

-v specify variable

OFS output delimiter (the default delimiter is a space, if there is no comma between two variables, the delimiter will not be used and the output will be concatenated)

FS input delimiter (same as direct-F effect)

Pattern

Null mode

BEGIN: actions before starting

END: operation after completion

Relational operation mode

Example of operator meaning = greater than or equal to

= = equal to

! = not equal to

~ match with the corresponding regular x ~ / regular /! ~ does not match the corresponding regular x! ~ / regular /

Variable

FS: enter delimiter, default white space character

OFS: output delimiter, default white space character

RS: enter newline character

ORS: output newline character

NF: how many columns is the current row divided into

NR: line number

FNR: when working with multiple files, each file records its own line number

FILENAME: current file name

ARGC: the number of command line parameters

ARGV: an array that holds the parameters given by the command line

Custom variable

-v assignment

Internal direct definition

Printf formatted output

Use the printf command instead of print for formatted output

What is the use of the awk command in linux? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to 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

Internet Technology

Wechat

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

12
Report