Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

awk command issue

zgrep 'MobileDevice' xyz.log.20181121.gz|grep 'USER123'| awk '$0>= "2018-Nov-21 00:01" && $0<="2018-Nov-21 23:59"' | awk -F '|' '$24>300 {print}'
above grep printing all the columns successfully satisfying abov condition of


Now i need to filter above query based on the state like Florida which is printing in 23rd column i.e $23

zgrep 'MobileDevice' xyz.log.20181121.gz|grep 'USER123'| awk '$0>= "2018-Nov-21 00:01" && $0<="2018-Nov-21 23:59"' | awk -F '|' '$23=FLORIDA {print}'

above query not working

how to check String equality in AWK

Please advise
Avatar of noci

= is assignment  / == is comparing for equality
FLORIDA is a variable...
so try $23 == "FLORIDA" as condition.
Avatar of gudii9


if i have to give both together how i do it?

zgrep 'MobileDevice' xyz.log.20181121.gz|grep 'USER123'| awk '$0>= "2018-Nov-21 00:01" && $0<="2018-Nov-21 23:59"' | awk -F '|' '$24>300  | awk -F '|' '$17==300 {print}'

above giving as below

then expecting something

i am confused where to start ' and where to end it '

please advise
Avatar of gudii9


so try $23 == "FLORIDA" as condition.
did not work
please advise
any sample commands like this in any link or resource or book?
What exactly is the context and what problem you are trying to solve....
More background please.

the awk equal comparison operator is '==' like noci said.

Read up here for examples.

Avatar of Pierre François
Pierre François
Flag of Belgium image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial