The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
"syntax error near unexpected token `fi' " GIC1986 SUN Solaris 4 09-19-2008 01:17 PM
Getting error "syntax error at line 78 : `<' unmatched" sshah1001 Shell Programming and Scripting 1 05-08-2008 06:41 PM
Egrep cheat sheet anywhere? Looking for meaning of egrep -c leelm UNIX for Dummies Questions & Answers 2 01-11-2008 03:37 PM
"syntax error at line 21 :'done' unexpected." error message" ibroxy Shell Programming and Scripting 3 08-08-2007 07:45 AM
help with egrep syntax Gerry405 UNIX for Dummies Questions & Answers 3 08-06-2005 03:01 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-13-2008
sagarjani sagarjani is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 6
search ")" with egrep - egrep: syntax error

Hi Guys,
we have a shell script which basically query the Database which retrieves huge data and use the data with "egrep" .

Now there is some data which contains characters like "abc)" and the same is used like below :

"egrep (.+\|GDPRAB16\|GDPR/11702 96 abc)\|$ temp.txt"

now while executing the above command it gives following error:
egrep: syntax error

The reason is that search pattern contains ")" character.

Is there a way to overcome this ?

Thanks in advance,
  #2 (permalink)  
Old 10-13-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,789

Code:
egrep '(.+\|GDPRAB16\|GDPR/11702 96 abc\)\|$)' temp.txt

I have no idea if this will work but I think the regex has correct syntax now.
  #3 (permalink)  
Old 10-14-2008
sagarjani sagarjani is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 6
Sorry the actual command I am trying to execute is :

egrep '.+\|GDPRAB16\|GDPR/11702 96 STREET REAR)\|$ /tmp/TTV_FILE_3862.txt'
  #4 (permalink)  
Old 10-14-2008
sagarjani sagarjani is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 6
Guys anybody know hoe to handle bracket ")" inside egrep command ?
  #5 (permalink)  
Old 10-14-2008
sivakumar.rj sivakumar.rj is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 74
The ) brackets can be handled by using \( .*\). Usually regex will be handled like this only.
  #6 (permalink)  
Old 10-14-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,289
As Jim wrote in his example, you should let the name of the file you want to grep, out of the single quotation marks:

Code:
egrep '.+\|GDPRAB16\|GDPR/11702 96 STREET REAR)\|$' /tmp/TTV_FILE_3862.txt
                                                  ^
                                                here

  #7 (permalink)  
Old 10-14-2008
sagarjani sagarjani is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 6
Hi,
EVen if I do following as you suggested it gives the same problem :

<telus6@test5>egrep '.+\|GDPRAB16\|GDPR/11702 96 STREET REAR)\|$' /tmp/TTV_FILE_3862.txt
egrep: syntax error
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0