aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unix Shell Script for pulling the information based on ID
 
Similar Threads
Help with an SQL Statement
DTD - parameter entity
Working With Complex Data Types
Inheritance/one table for each class
JPA: Secondary tables +optimistic locking