• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need linux command.

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
test.xml.gz

<MyName Owner="Praneeth" Status="ALIVE">
<Empid>033516</Empid>
<DOB>2020</DOB>

command for one tag:----- zgrep '<EMPID>033516</EMPID>' test.xml.gz
i am getting expected result.


Now i want to search two tags <Empid>033516</Empid><DOB>2020</DOB> with the above command i am not getting expected result.
i know test.xml.gz contains both tags. but i am not getting this xml file.

can anyone please tell me the command to find the two tags.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With -E you get extended grep, extended by regular expressions. "(a|b|c)" means "find a or b or c":

Another approach, if DOB always follows Empid, and 2020 is allways following 033516 is, to print one additional line of output:



A third solution would go for the xml-structure. There are tools to search in xml like xmlstarlet, but I don't know how to use them



Maybe there is something more simple out there, than xmlstarlet.
 
reply
    Bookmark Topic Watch Topic
  • New Topic