Shell gawk (I) Basics

Source: Internet
Author: User

I. Command Format

Gawk options program file

Gawk options:

-F fs specifies the file delimiter used to describe the data fields in a row

-F file: Specifies the file name of the reader.

-V var = value defines the variables and default values used in the gawk program.

-Mf N specifies the maximum number of fields to be processed in the data file.

-Mr N specifies the maximum record size in the data file.

-W keyword: indicates the compatibility mode or warning level of gawk.

Ii. Read the program script from the command line

$ Gawk '{print "hello world "}'

(The default input file is STDIN)

3. Use data field variables

$0 full line of text

$ N data in the text line



The specified Delimiter is a space. By default <Strong? Http: www.bkjia.com kf ware vc "target =" _ blank "class =" keylink "> VcD4KCjxwPr/J0tTWuLaot9a49Lf7oaqhqs2ouf0gLUYgPC9wPgo8cD48aW1nIHNyYz0 = "" alt = "\">


4. Use multiple commands in the script


It can be used between variables and multiple commands.


5. Read program from file-f



To use multiple commands in a program, you only need to place one command in each line, without the need to use ";"

Vi. run scripts before and after Data Processing



Press ctrl + d to stop the input

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.