my dog learned polymorphism*
The moose likes Linux / UNIX and the fly likes Unix Shell Script for pulling the information based on ID Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Unix Shell Script for pulling the information based on ID" Watch "Unix Shell Script for pulling the information based on ID" New topic
Author

Unix Shell Script for pulling the information based on ID

sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
Hi,

The below address information is logged in the file x.log. If the user enters 2, iwant the address information starting with <address> ..</address> to be displayed
on the console. Is it better to use shell script. Any help is appreciated.

<ADDRESS>
<ID> 1</ID>
<STREET>ABC </STREET>
</ADDRESS>

<ADDRESS>
<ID> 2</ID>
<STREET>XYZ </STREET>
</ADDRESS>


regards
sudha
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

What do you want to be displayed?
XYZ?

would do the trick.

The 2 is the pattern to search for with grep.
-n1 gives 1 line of context before and behind.

tail -n1 only displays 1 line from the end backwards.
In a shell script xlogsearch.sh, you would write

and call it


http://home.arcor.de/hirnstrom/bewerbung
 
 
subject: Unix Shell Script for pulling the information based on ID