Abhishek dot py
Abhishek dot py

Reputation: 939

Awk conditional with multiple conditions

I am using awk to check if my data has values of 32th column is greater than 4000 and value of 60th column is less than 10. I am using below command, but it is not working, nor it is showing any error:

awk -F, '$32 > 4000' && '$60 < 10' *

I have , as separator and I am checking it in all the files in a folder.

Upvotes: 0

Views: 784

Answers (2)

SMA
SMA

Reputation: 37023

You could just combine multiple condition within one quote and use it like:

awk -F, '$32 > 4000 && $60 < 10' *

Upvotes: 1

fedorqui
fedorqui

Reputation: 289515

awk evaluates conditions within ' ' and you have two blocks of them, && being outside. So you have to put all this syntax within ' ':

awk -F, '$32 > 4000 && $60 < 10' *

Instead of:

awk -F, '$32 > 4000' && '$60 < 10' *
                   ^    ^

Upvotes: 3

Related Questions