yanivk1984
7/9/2019 - 10:57 AM

awk linux equel, contatins for if statement

# for string
awk '$3 ~ /snow/ { print }' dummy_file 

# for numeric
cpwd_admin list | awk '{if ($4==1) {print $1}}'

# check if column contains a string and print it, will print just the columns containing the lines
mpstat -P ALL 1 1 | awk '$12 ~ /idle/ {print $12}'

# check if column contains a string and print it, if matched string, print all the values in this column
mpstat -P ALL 1 1 | awk '$3 ~ idle {print $12}'

# print specific columns with conditions
awk '$7 > 100 || $8 > 100' filename