Example of the awk instance of Linux

Source: Internet
Author: User
An instance of awk is detailed in the instance file:
 1  root x 0 0 root /root /bin/bash 2  bin x 1 1 bin /bin /sbin/nologin 3  daemon x 2 2 daemon /sbin /sbin/nologin 4  adm x 3 4 adm /var/adm /sbin/nologin 5  1p x 4 7 1p /var/spool/1pd /sbin/nologin 6  shutdown x 6 0 /sbin /sbin/shutdown
I. AWK command format
           awk参数           找谁      干啥             文件awk    [ options ]       ‘pattern {action}’          file
Two. Example Demo
打印大于等于第二行的第1列和第3列数据[[email protected] kang]# awk ‘NR>=2{print $1,$3}‘ test2.txt bin 1daemon 2adm 31p 4shutdown 6小结awk执行过程1.awk读入第一行内容2.判断是否符合模式中的条件(N$>=2)    如果匹配默则执行对应的动作{print $1,$2}    如果不匹配条件,继续读取下一行3.继续读取下一行

Example of the awk instance of Linux

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.