Awk study Note 6: awk mode and action

Source: Internet
Author: User
Each awk statement consists of a pattern and corresponding actions. The execution of the pattern control rule in the awk-a rule is executed when its pattern matches the current input record.
Special begin and end modes:
They provide awk ProgramStart and end actions,
The begin and end rules must have actions. They are executed only once in the program.
For example:
$ Awk 'in in {print "Analysis of \" foo \ ""}/Foo/{++ n} end {print "\" foo \ "appears", n, "Times. "} 'filename'
The begin rule prints the title, and the end rule prints the value of N.
An awk program can have multiple begin/end rules. They are executed in the order of appearance.

An action is composed of one or more awk statements starting with a pair of {} loops. Each statement performs one task. Each statement is separated by a new line or a comma.

Related Article

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.