search ")" with egrep - egrep: syntax error


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers search ")" with egrep - egrep: syntax error
# 1  
Old 10-13-2008
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  
Old 10-13-2008
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  
Old 10-14-2008
Sorry the actual command I am trying to execute is :

egrep '.+\|GDPRAB16\|GDPR/11702 96 STREET REAR)\|$ /tmp/TTV_FILE_3862.txt'
# 4  
Old 10-14-2008
Guys anybody know hoe to handle bracket ")" inside egrep command ?
# 5  
Old 10-14-2008
The ) brackets can be handled by using \( .*\). Usually regex will be handled like this only.
# 6  
Old 10-14-2008
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  
Old 10-14-2008
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Explanation around "+r" in egrep

Hi, Is anyone able to shed some light on "+r"? I know -r in grep refers to a recursive search - I am curious to know what +r specifies. #show process pidin | utility egrep -e "+r" count 2492 Thanks. (3 Replies)
Discussion started by: sand1234
3 Replies

2. BSD

Keep getting error "-bash: ./.profile_z2: line 52: syntax error: unexpected end of file"

#!/bin/bash #-------------------------------------------------------- # Setup prompt # Author Zeeshan Mirza # Data: 06-08-2017 #-------------------------------------------------------- if then . ./.profile_custom_pre fi umask 022 set -o vi export EDITOR=vi export VISUAL=vi... (3 Replies)
Discussion started by: getzeeshan
3 Replies

3. UNIX for Dummies Questions & Answers

Egrep confusion with "I" and "-I" pattern

I am executing following command egrep -w I filename.txt the filename.txt has following data .... -I 07-18 08:31:19.924 9880 6 SessionManager ConnectConfig: ConfigurationWebService LoginResults=SuccessfulLogin I am so hungry that I need to eat I expect egrep to print only the second... (1 Reply)
Discussion started by: VBG
1 Replies

4. Shell Programming and Scripting

Help with FTP Script which is causing "syntax error: unexpected end of file" Error

Hi All, Please hav a look at the below peice of script and let me know if there are any syntax errors. i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies

5. Shell Programming and Scripting

Escaping backslash and asterisk in egrep to match "\*"

So far what i've got is egrep '^(\\)\*$'No luck. I've searched the web and not much luck. I know about the escape character \ but its confusing to figure out how to use it to match a backslash and use it to escape the asterisk also. Any ides? Thanks! (8 Replies)
Discussion started by: matthewfs
8 Replies

6. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

7. Shell Programming and Scripting

egrep -i "(from|to)=<$1>" mail.log ?

Hi, As you can see I'm trying to get email addresses from the mail.log. This is a part of a bash shell script I found but I#m wondering how I can check the variable $1? When I try egrep -i "(from|to)=<$1>" mail.log | awk ' {print $1}' either from the command line or from a script it... (12 Replies)
Discussion started by: kajax
12 Replies

8. Shell Programming and Scripting

egrep syntax error

I have a script that has been running fine for about a month - now all of a sudden I am getting a syntax error using the egrep command. The command I am using is comparing two files and printing only the unique lines from Second_File to Third_File. Any idea why I am getting the syntax error?? ... (4 Replies)
Discussion started by: bjdamon
4 Replies

9. UNIX for Dummies Questions & Answers

How to use the "grep/egrep" command to search files.

Hi Team, I am new to this forum and also trying to learn Unix. I will highly appriciate your help if you can help me to get the right command . {{{ I use the command " today | egrep '(10:| 11: )' | grep ERROR " to grep all the files that has been error betweeen 10 to 11... (6 Replies)
Discussion started by: rkhanal
6 Replies

10. Shell Programming and Scripting

"syntax error at line 21 :'done' unexpected." error message"

I am trying to run the script bellow but its given me "syntax error at line 20 :'done' unexpected." error message" can someone check to see if the script is ok? and correct me pls. Today is my first day with scripting. Gurus should pls help out #!/bin/ksh # Purpose: Check to see if file... (3 Replies)
Discussion started by: ibroxy
3 Replies
Login or Register to Ask a Question