File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes grep related question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "grep related question" Watch "grep related question" New topic

grep related question

Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136


I am trying to find a particulat line from a file.
My ksh code as below

But this doesn't evaluate $KEY so doesn't return any line.
How can I achieve that?

Thanks and Regards,
Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136

I could figure this out, the solution is:

`grep '^'"$KEY"'_somestring' someFile.txt | awk -F= '{print $2}'`

Anand Hariharan

Joined: Aug 22, 2006
Posts: 257

You don't need to grep and pipe it to awk. This -

- should suffice.

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
Consider Paul's rocket mass heater.
subject: grep related question
Similar Threads
what is the benefit of using the reverse search by pressing CTRL+R?
Search on a string
How to read each line from file in Shell script
how to retrieve the value of ps - A command
script to email if tomcat has stopped