File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Make it so: Java DB Connections & Transactions
this week in the
Linux / UNIX
Unix Shell Script for pulling the information based on ID
Joined: Apr 24, 2007
Oct 04, 2007 14:26:00
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.
Joined: Jun 02, 2003
Oct 05, 2007 19:36:00
What do you want to be displayed?
grep -n1 2 x.log | tail -n 1
would do the trick.
The 2 is the
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
#!/bin/bash grep -n1 $1 /path/to/x.log | tail -n 1
and call it
I agree. Here's the link:
subject: Unix Shell Script for pulling the information based on ID
Inheritance/one table for each class
Working With Complex Data Types
DTD - parameter entity
JPA: Secondary tables +optimistic locking
Help with an SQL Statement
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015