It's not a secret anymore!
The moose likes Linux / UNIX and the fly likes need linux command. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "need linux command." Watch "need linux command." New topic

need linux command.

praneeth ram
Ranch Hand

Joined: Sep 21, 2009
Posts: 60

<MyName Owner="Praneeth" Status="ALIVE">

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.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

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.
I agree. Here's the link:
subject: need linux command.
It's not a secret anymore!