Avatar of gudii9
Flag 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
LinuxLinux SecurityLinux NetworkingUnix OSLinux Distributions

Avatar of undefined
Last Comment
Pierre François

8/22/2022 - Mon

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

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

so try $23 == "FLORIDA" as condition.
did not work
please advise
any sample commands like this in any link or resource or book?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

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.

Pierre François

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question