1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| $ awk '$1>2' log.txt $ awk -F: '$3 + $4 > 2000{print $0}' /etc/passwd $ awk -F: '$3 + $4 > 2000 && $3 * $4 > 2000{print $0}' /etc/passwd
$ awk '$2 ~ /th/ {print $2,$4}' log.txt --------------------------------------------- this a
$ awk '/re/ ' log.txt --------------------------------------------- 3 Do you like awk 10 There are orange,apple,mongo
格式化打印: $ awk -F: 'BEGIN{OFS=" | "}{printf "|%+15s|%-15s|\n", $NF, $1}' /etc/passwd | : 以 | 为分隔符 |%+15s| : 以 | 为分隔符 %s 配合 printf 使用 代替当前字符串 右对齐 占用 15 字符
|