Linux awk Command

Source: Internet
Author: User

awk is a language for working with text files, a powerful text analysis tool, and awk is the initials of the three founders.

Syntax:

awk [option parameter] ' script ' Var=value file (s) or awk [option parameter]-F scriptfile var=value file (s)


Option parameter description:

-F FS or--field-separator FS

Specifies the input file delimiter, FS is a string or is a regular expression, such as-f


-V Var=value or--asign var=value

Assigning a user-defined variable

-MF nnn AND-MR nnn

Set intrinsic limits on the NNN value, the-MF option limits the maximum number of project blocks assigned to NNN, the-MR option limits the maximum number of records, and these two features are the extended functionality of the Bell Lab version of AWK, which is not applicable in standard awk.


-W compact or--compat,-w traditional or--traditional

Run awk in compatibility mode, so gawk behaves like standard awk, and all awk extensions are ignored.


Example:

$ Awk-va=1 ' {print $1,$1+a} ' Log.txt

2 3

3 4

This ' s 1

10 11

$ Awk-va=1-vb=s ' {print $1,$1+a,$1b} ' Log.txt

2 3 2s

3 4 3s

This ' s 1 this ' SS

10s


Operator:




Linux awk Command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.