cat /tmp/i.txt
'(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic Phone|ENCRYPTION)'
grep -ia 'ORA-[0-9]\{5\}:' Rep* |grep -iavE `cat /tmp/i.txt`
grep: Unmatched ( or \(
Please tell me why am i getting that
Aia
May 11, 2017, 12:23pm
2
jhonnyrip:
cat /tmp/i.txt
'(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic Phone|ENCRYPTION)'
grep -ia 'ORA-[0-9]\{5\}:' Rep* |grep -iavE `cat /tmp/i.txt`
grep: Unmatched ( or \(
Please tell me why am i getting that
`cat /tmp/i.txt
` That outputs the content of /tmp/i.txt to grep and it interprets it as:
grep -iavE Regex FileName
Regex
'(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic
FileName
Phone|ENCRYPTION\)'
Do you see how it doesn't work?
What are you trying to do?
grep ORA- from log files and ignore all pattern in i.txt
Hi johnnyrip,
Please get into the habit of telling us what operating system and shell you're using when you post questions like this!
With your specific example, the following might work:
grep -ia 'ORA-[0-9]\{5\}:' Rep* |grep -iavE "$(tr -d "'" < /tmp/i.txt)"
depending on what shell you're using. (It will not work with an original Bourne shell.)
jhonnyrip:
cat /tmp/i.txt
'(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic Phone|ENCRYPTION)'
grep -ia 'ORA-[0-9]\{5\}:' Rep* |grep -iavE `cat /tmp/i.txt`
grep: Unmatched ( or \(
Please tell me why am i getting that
Hi,
there is a space in the file
...ORA-06512|Domestic Phone|ENCRYPTION)'
---------------------^
You may try this:
grep -ia 'ORA-[0-9]\{5\}:' Rep* |grep -iavE "`cat /tmp/i.txt`"
...to avoid the shell's interpretation of the space.
Regards!
abelluis:
Hi,
there is a space in the file
...ORA-06512|Domestic Phone|ENCRYPTION)'
---------------------^
You may try this:
grep -ia 'ORA-[0-9]\{5\}:' Rep* |grep -iavE "`cat /tmp/i.txt`"
...to avoid the shell's interpretation of the space.
Regards!
Note that according to post #1 , the text in /tmp/i.txt
contains leading and trailing single-quotes. It isn't clear to me whether those quotes were intended to quote the ERE being passed to the second grep
or whether they are literal quotes that are to be matched by the ERE before and after one of the alternatives in the ERE. Your code assumes they are characters to be matched by the ERE. I thought they were intended to quote the ERE. Without a sample input file (i.e., one of the files matched by the filename matching pattern Rep*
) we'll never know what the intent was. About all that we can say with any certainty is that the portion of the ERE that is the string |ORA-1017|
is probably missing a digit somewhere before, after, or in the middle of 1017
(since the first grep is throwing away lines that don't have 5 digits after ORA-
).
@Don Cragun
This is the way that bash evaluates the single quote in Debian:
~$: grep -ia 'ORA-[0-9]\{5\}:' Rep* | grep -iavE "`cat /tmp/i.txt`"
+ grep -ia 'ORA-[0-9]\{5\}:' Rep-date
++ cat /tmp/i.txt
+ grep -iavE ''\''(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic
Phone|ENCRYPTION)'\'' '
ORA-20000:
ORA-20000:
ORA-20000:
ORA-20000:
Regards.
---------- Post updated at 09:22 PM ---------- Previous update was at 08:38 PM ----------
jhonnyrip:
cat /tmp/i.txt
'(ORA-28001|ORA-00100|ORA-28001|ORA-20026|ORA-20025|ORA-02291|ORA-01458|ORA-01017|ORA-1017|ORA-28000|ORA-06512|ORA-06512|Domestic Phone|ENCRYPTION)'
grep -ia 'ORA-[0-9]\{5\}:' Rep* |grep -iavE `cat /tmp/i.txt`
grep: Unmatched ( or \(
Please tell me why am i getting that
You also can do it more simply,
cat /tmp/i.txt
ORA-28001
ORA-00100
ORA-28001
ORA-20026
ORA-20025
ORA-02291
ORA-01458
ORA-01017
ORA-1017
ORA-28000
ORA-06512
ORA-06512
Domestic Phone
ENCRYPTION
And then:
grep -ia 'ORA-[0-9]\{5\}:' Rep* | grep -iavE -f /tmp/i.txt
Regards.