This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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: 186
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
 
Have you checked out Aspose?
 
subject: Unix Shell Script for pulling the information based on ID
 
jQuery in Action, 3rd edition