• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

grep related question

 
Sujoy Choudhury
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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?
 
Sujoy Choudhury
Ranch Hand
Posts: 136
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could figure this out, the solution is:

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


 
Anand Hariharan
Rancher
Posts: 272
C++ Debian VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to grep and pipe it to awk. This -

- should suffice.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic