取出某列数值大于指定数据的行数据(如:第9列数据中大于1的行数据是那些)
cat 1.txt
08:23:18 up 18 min, 1 user, load average: 0.35, 0.33, 0.33
08:23:19 up 18 min, 1 user, load average: 0.32, 1.33, 0.33
08:23:20 up 18 min, 1 user, load average: 0.32, 0.33, 0.33
08:23:20 up 18 min, 1 user, load average: 1.32, 0.33, 0.33
08:23:21 up 18 min, 1 user, load average: 0.32, 0.33, 0.33
08:23:21 up 18 min, 1 user, load average: 0.32, 0.33, 1.33
# 获取第9列数据中大于1的数据行
awk '$11>1.00 {print}' 1.txt
08:23:21 up 18 min, 1 user, load average: 0.32, 0.33, 1.33
awk支持正则(如:提取第9,10,11列中大于1的行数据)
# 获取第9行、10、11列中大于1的行数据
awk '$9>1.00|| $10>1 || $11>1 {print}' 1.txt
08:23:19 up 18 min, 1 user, load average: 0.32, 1.33, 0.33
08:23:20 up 18 min, 1 user, load average: 1.32, 0.33, 0.33
08:23:21 up 18 min, 1 user, load average: 0.32, 0.33, 1.33
如果是非数字也会打印
cat 1.txt
08:23:18 up 18 min, 1 user, load average: 0.35, 0.33, ns
08:23:19 up 18 min, 1 user, load average: 0.32, 1.33, 0.33
08:23:20 up 18 min, 1 user, load average: 0.32, bn, 0.33
08:23:20 up 18 min, 1 user, load average: 1.32, 0.33, 0.33
08:23:21 up 18 min, 1 user, load average: 0.32, 0.33, 0.33
08:23:21 up 18 min, 1 user, load average: 0.32, 0.33, 1.33
awk '$9>1.00|| $10>1 || $11>1 {print}' 1.txt
08:23:18 up 18 min, 1 user, load average: 0.35, 0.33, ns
08:23:19 up 18 min, 1 user, load average: 0.32, 1.33, 0.33
08:23:20 up 18 min, 1 user, load average: 0.32, bn, 0.33
08:23:20 up 18 min, 1 user, load average: 1.32, 0.33, 0.33
08:23:21 up 18 min, 1 user, load average: 0.32, 0.33, 1.33