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
Problem with GREP. syndex Shell Programming and Scripting 2 07-11-2007 10:44 AM
grep problem asal_email2 UNIX for Dummies Questions & Answers 4 06-22-2005 05:49 PM
grep problem svennie UNIX for Dummies Questions & Answers 5 11-08-2004 01:29 AM
Grep Problem lesstjm Shell Programming and Scripting 2 10-27-2004 07:13 AM
Grep problem odogbolu98 Shell Programming and Scripting 3 02-18-2003 12:53 PM

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

Join Date: May 2008
Posts: 14
GREP problem

I have a problem. Suppose I have a log named transport.log
>>
tp finished with return code: 203
meaning:
wrong syntax in tp call
....
tp finished with return code: 0
meaning:
Everything ok.
<<

What i want to do is to get the return code of the 1st one. So I would probably do:
Code:
tempVar=`head -1 transport.log`
My problem is, I want to know if the return code is 0
I can't do
check=`grep -w 0 $tempVar` since it returns an error
How do I go around this since I need to check the return code twice in the transport.log Since there are 2 return codes.

Last edited by Yogesh Sawant; 05-13-2008 at 06:15 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2  
Old 05-12-2008
Registered User
 

Join Date: Feb 2006
Posts: 3
how about something like this :
Code:
FIRSTRC=` grep "return code:" file | head -1 | awk -F: ' { print $2 } '`
LASTRC=` grep "return code:" file | tail -1 | awk -F: ' { print $2 } '`

Last edited by Yogesh Sawant; 05-13-2008 at 06:15 AM. Reason: added code tags
Reply With Quote
  #3  
Old 05-12-2008
Registered User
 

Join Date: May 2008
Posts: 14
H

Hi, thanks for the quick reply. I'll give it a go right now
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:13 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