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

Example Analysis of basic parameters of awk

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly shows you the "sample analysis of the basic parameters of awk", which is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of the basic parameters of awk".

Awk is good at manipulating files one line at a time, reading one line at a time, and then acting accordingly. The basic syntax format of awk when reading a single file is awk 'BEGIN {OFS=FS= "\ t"} {print $0, $1;}' filename's syntax when reading multiple files is awk...

Awk is good at manipulating files one line at a time, reading one line at a time, and then acting accordingly.

The basic syntax format for awk to read a single file is

Awk 'BEGIN {OFS=FS= "\ t"} {print $0, $1;}' filename

The syntax when reading multiple files is

Awk 'BEGIN {OFS=FS= "\ t"} ARGIND==1 {print $0, $1;} ARGIND==2 {}' file1 file2

The command part after the awk is enclosed in quotation marks, which can be single quotation marks or double quotation marks, but be careful not to be the same as the quotation marks used in the internal command, otherwise the nearest quotation marks will be regarded as a group, causing an interpretation error.

OFS: column delimiter (output field separtor) for file output

FS: column delimiter (field separtor) when the file is imported

BEGIN: set initial parameters, initialize variables

END: do the final processing after reading the file

Other {}: loop through every line of the file

$0 represents a line of content; $1, $2, … $NF represents the first column, the second column to the last column.

How many columns are there in the NF (number of fields) file; how many lines have been read in the NR (number of rows) file: how many lines have been read in the current FNR file, which is often used in multi-file operations.

The above is all the contents of the article "sample Analysis of awk basic parameters". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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

Development

Wechat

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

12
Report