I am trying to use multiple 'AND' and 'OR' condition in awk but it is not giving me the desired output. Instead it doesn't read the last &&
conditions that i have given with time '030000'.
awk -F, '{if(substr($2,1,3)=="301" && $15=="996" || $15=="429" && $5>=030000 && $5<=035000) print $2"|"$15"|"$5}' 2017020* | head -10
3014241320|996|235939
3017943809|996|235953
Looks like you missed parentheses around the OR
operation. It should be:
if(substr($2,1,3)=="301" && ($15=="996" || $15=="429") && $5>=030000 && $5<=035000) ...
See boolean algebra.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With