2. Text Analysis tool-awk

Source: Internet
Author: User
Tags first string

General format of the awk command:

awk ' {pattern + action} ' {Filenames}


Call awk:

1. Command-line mode:awk[-F Field-separator]'commands'input-file(s) commands is the real awk command, [-f Domain delimiter] is optional. input-file(s) is the file to be processed. 2The . Shell script will input all awk commands into the file, and then the awk command interpreter as the first line of the script (#bin/awk). 3Insert all awk commands into a separate file, and then call:awk-Fawk-script-fileinput-file(s) among them,The-f option loads the awk script in Awk-script-file.

Built-in variable table:

$ Current record (as a single variable)
$1~ $n The nth field of the current record, separated by FS between fields
Fs Input field delimiter is blank by default
Nf The number of fields in the current record, that is, how many columns
Rs Enter the delimiter for the record, which is the line break by default
OFS Output field delimiter is blank by default
ORS Output record delimiter, default is line break
ARGC Number of command line arguments
Argv Array of command-line arguments
FILENAME Current input file name
IGNORECASE If true, the matching of the case is ignored
Argind argv identifier of the currently processed file
Convfmt Digital conversion Format%.6g
ENVIRON UNIX Environment variables
Errno UNIX System error messages
FieldWidths Blank delimited string for input field width
FNR Current Record Count
Ofmt The output format of the number%.6g
Rstart The first string matched by the matching function
Rlength String lengths matched by matching function
Subsep \034

2. Text Analysis tool-awk

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.