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
How to Convert Hex value to Dec ? Nayanajith Shell Programming and Scripting 6 08-05-2008 01:30 AM
convert to GB melanie_pfefer Shell Programming and Scripting 6 03-03-2008 10:05 AM
to convert int to hex naan High Level Programming 8 12-21-2007 11:13 AM
How to convert Dat to Bin ravi.sadani19 UNIX for Advanced & Expert Users 3 08-06-2007 08:03 AM
here-doc convert 2 script convert to single script? yongho Shell Programming and Scripting 2 07-07-2005 01:14 PM

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

Join Date: Feb 2005
Posts: 68
How to convert grep to sed??

Hi,

I am hing problem in grep..
So I need convert following code to sed based one..

grep -ie "error|exception" $LOG_DIR/Node$i\Log.txt >> $LOG_ERR_REP

thats is I want to serach error and exception (ignore case) and write to other file .

how to do?
Reply With Quote
Forum Sponsor
  #2  
Old 05-16-2005
Registered User
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
You can try as,

sed -e "/[eE][rR][rR][oO][rR]/p;/[eE][xX][cC][eE][pP][tT][iI][oO][nN]/p" $LOG_DIR/Node$i\Log.txt >> $LOG_ERR_REP

It will work.
Reply With Quote
  #3  
Old 05-16-2005
Registered User
 

Join Date: Feb 2005
Posts: 68
Hi,
Thanks for your help..
But its giving file not containing Error (error) and Exception(and exception) line too???
Reply With Quote
  #4  
Old 05-16-2005
Registered User
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
There is an error in my reply. use this,
sed -n '/[eE][rR][rR][oO][rR]/p;/[eE][xX][cC][eE][pP][tT][iI][oO][nN]/p' $LOG_DIR/Node$i\Log.txt >> $LOG_ERR_REP
Reply With Quote
  #5  
Old 05-16-2005
Registered User
 

Join Date: Feb 2005
Posts: 68
thanks ..its working
Reply With Quote
  #6  
Old 05-16-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Quote:
Originally Posted by redlotus72
Hi,

I am hing problem in grep..
So I need convert following code to sed based one..

grep -ie "error|exception" $LOG_DIR/Node$i\Log.txt >> $LOG_ERR_REP

thats is I want to serach error and exception (ignore case) and write to other file .

how to do?
Firstly, what is wrong with your grep? I suspect you are using GNU grep and want extended regexes - in which case you need upper case -E

grep -i -E "error|exception" file >> another_file

Or, if you're not using GNU grep

egrep -i "error|exception" file >> another_file

Also; why are you backslash escaping the L of Log.txt?

Cheers
ZB
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 05:03 AM.


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