Syntax error with if statement and if statement

I'm trying to run the following, but I clearly have a syntax error and I'm not really sure what it is. I would appreciate some help.

cat $file | awk '{if (($2 & 0x40) != 0) print $1; else {}}'

      

+3


source to share


1 answer


awk does not support bitwise operators. However, if you have gawk (GNU awk), you can do:

gawk '{ if (and($2,0x40) != 0) print $1; }' $file

      



Note that I removed the empty else clause and the unnecessary one cat

.

See the manual for other bitwise operators and usage in gawk.

+4


source







All Articles