The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
redirect the grep output into the variable mail2sant Shell Programming and Scripting 1 04-08-2008 06:46 AM
Set a variable from awk output Cranie UNIX for Dummies Questions & Answers 3 10-11-2007 06:39 AM
output of grep useless79 Shell Programming and Scripting 3 09-18-2007 02:36 AM
how to output awk to a variable bashirpopal UNIX for Dummies Questions & Answers 4 04-02-2003 08:02 AM
capturing the output of grep as integer variable babariba UNIX for Dummies Questions & Answers 2 11-16-2001 07:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-23-2008
Registered User
 

Join Date: May 2005
Posts: 192
Put the output of grep in a variable

Hi,
in a shell script how can I put the result of a grep command in a variable :
myvariable=grep mystring myfilename

Thank you.
Reply With Quote
Forum Sponsor
  #2  
Old 04-23-2008
Registered User
 

Join Date: Jul 2006
Posts: 189
myvariable=$(grep mystring myfilename)
Reply With Quote
  #3  
Old 04-23-2008
Dave Miller's Avatar
Registered User
 

Join Date: Dec 2007
Location: Northern NJ, USA
Posts: 150
Hmmm...

I would have said:

myvariable=`grep mystring myfilename`
Reply With Quote
  #4  
Old 04-23-2008
Registered User
 

Join Date: May 2005
Posts: 192
Thanks to all.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0