The use of awk and the output of printf format
1 basic usage awk-F:'{print$1}'/ etc/passwd # shows the user name of passwd awk-F:'$NF== "/ bin/bash" {print$1, $NF}'/ etc/passwd # shows the user awk 'BEGIN {print "beginning"} {print$0} END {print "}' / etc/passwd # BENGIN with shell as" / bin/bash "can be understood as a page header END is understood as footer df-h | awk-F%'/ ^\ / dev/ {print $1}'| awk'{if ($5 > = 20) print $1 # 5 "%"} # matches dev first, and the one that begins with dev is really mounted to find those with disk space greater than 20%. The idea is to first cut the first section of the pipe into two segments with%. This is the desired value of $5. If the comparison is greater than 20, output awk'{FS= ":" OFS= "- -"} {print NR,$1,$2,$3}'/ etc/passwd # is delimited by: awk-F for the use of the output delimiter 2.AWK if ":"'{if ($1mm = "root") print$0}'/ etc/passwd # used by a single if, the first field is displayed when the content is equal to "root". Awk-F ":'($1percent =" root ") {print$0}'/ etc/passwd # another way of writing, as above, without the need for if to use (), awk-F": "'{if ($1mm =" root ") next} {print$0}'/ etc/passwd # for single if use, the first field equals" root "is skipped, the display behind, and the opposite of the above shows # next directly skipped this time, exit exits directly But if you have EOF, you still need to execute the content of EOF awk-F:'{if (NR > = 2&&NR).