How to print $2 by awk only if the fourth field is not 0 (zero).
line="root 13246 11314 457 15: qsRw -m1"
then awk will print 13246, but if
line="root 13246 11314 0 15: qsRw -m1"
then awk will not print anything
How to print $2 by awk only if the fourth field is not 0 (zero).
line="root 13246 11314 457 15: qsRw -m1"
then awk will print 13246, but if
line="root 13246 11314 0 15: qsRw -m1"
then awk will not print anything
awk '$4!=0{print $2}' file
or just
awk '$4{print $2}' file
The syntax of awk is
awk '/pattern/{action}' file
the "pattern" part is actually an implicit "if" control flow structure. Therefore you can omit putting an "if" keyword.