Skip to content

Instantly share code, notes, and snippets.

@mkol5222
Forked from yanivk1984/awkIf.sh
Created March 13, 2025 11:35
Show Gist options
  • Save mkol5222/bcff84c8314c0fd019666948d42b0985 to your computer and use it in GitHub Desktop.
Save mkol5222/bcff84c8314c0fd019666948d42b0985 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment