The ~ is a RE match (Regular Expression).
Indeed it means "contains".
RE has got some special characters. For example, anchor characters
$1~/^timeout:$/
sais it must span from the beginning to the end. And then is identical with
$1=="timeout:"
This is a pre-selector, a condition.
Within { } there is the full awk language. You can write it like
Code:
xset q | awk '{ if ($1=="timeout:") {print $2} }'
If you have multiple columns and don't know which column it is, have a loop:
Code:
xset q | awk -v search="timeout:" '{ for (k=1;k<NF; k+=2) { if ($k == search) { print $(k+1) } } }'
Now you can also search "cycle:"
The -v assigns to an awk variable.