Shell character intercept command awk

Source: Internet
Author: User

  1. awk command
    # awk ' Condition 1{action 1} Condition 2{action 2} .... ' Filename
    General use of relational expressions as criteria
    Action: 1, formatted output 2, Flow control statement

  2. column that handles the cut command cannot intercept spaces

    Example: Intercepting disk usage

    DF- H | grep "sda1" | awk ' Begin{print ' This was sda1 hard use persent: '} {print $} ' | Cut- F 1-d "%"

  3. Begin keyword

    A, before all actions are processed, you can add a script comment in the first line of the output text (as in the previous example)

    b, custom intercept characters, use FS, must add begin, delete first row

  4. FN Built-in variables

    Custom Intercept characters

    awk ' {fs= ': "}{print" \ T "$ /etc/passwd } '

    Need to be modified to

    awk ' begin{fs= ': "}{print" \ T "$ /etc/passwd "

  5. End keyword

    Command finishes, add end comment at end of output text

    awk ' End{print ' This is END test!! '} {fs= ":"} {print $ \ t ' $ /etc/passwd } '

  6. Relational operators

    Displays disks with a disk share of more than 5%

    DF- H | awk ' $5>5{print ' \ t ' $ ' | Cut- F 1-d "%"

Shell character intercept command 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.