We help IT Professionals succeed at work.

awk command issue

187 Views
Last Modified: 2019-01-10
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

$24>300


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
Comment
Watch Question

nociSoftware Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

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

Author

Commented:
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

Author

Commented:
so try $23 == "FLORIDA" as condition.
did not work
please advise
any sample commands like this in any link or resource or book?
nociSoftware Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
What exactly is the context and what problem you are trying to solve....
More background please.
CERTIFIED EXPERT

Commented:
Hi,

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

Read up here for examples.

Cheers
Senior consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.