Visit The New, Modern Unix Linux Community


Help with simple RegEx on grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with simple RegEx on grep
# 1  
Help with simple RegEx on grep

Hello,

I am trying to grep my log files for ORA errors, except ORA-00001.
I have tried:
grep 'ORA*!(-00001)' *.log
but it is not working.

Any help will be much appreciated.
Thank you.
# 2  
Try:
Code:
awk '/ORA/&&!/ORA-00001/' file

This User Gave Thanks to cabrao For This Post:
# 3  
Code:
sed -n '/ORA-[0-9][0-9]*[^00001]/p'

This User Gave Thanks to ygemici For This Post:
# 4  
@ygemici. That will not work ([^00001] is equivalent to [^01]):
Code:
$ echo ORA-00011 | sed -n '/ORA-[0-9][0-9]*[^00001]/p'
$

Try this:
Code:
sed '/ORA-00001/d;/ORA/!d' infile

This User Gave Thanks to Scrutinizer For This Post:
# 5  
Quote:
Originally Posted by Scrutinizer
@ygemici. That will not work ([^00001] is equivalent to [^01]):
Code:
$ echo ORA-00011 | sed -n '/ORA-[0-9][0-9]*[^00001]/p'
$

Try this:
Code:
sed '/ORA-00001/d;/ORA/!d' infile

thanks friend Smilie i have written this urgently i have forgotten other conditions..
however if we only except `ORA-00001` we can use this
Code:
sed -n '/ORA-/{;/00001/!p;}' infile

regards
ygemici
This User Gave Thanks to ygemici For This Post:
# 6  
Code:
grep 'ORA' *.log |grep -v "-00001"

This User Gave Thanks to rdcwayx For This Post:

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #267
Difficulty: Easy
In 1935, at the age of 22, Alan Turning was elected a fellow of King's on the strength of a dissertation in which he proved the central limit theorem.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep in regex

Hello guys, Here i am writing a script in bash to check for a valid URL from a file using regex This is my input file http://www.yahoo.commmmmm http://www.google.com https://www.gooogle.co www.test6.co.in www.gmail.com www.google.co htt://www.money.com http://eeeess.google.com... (2 Replies)
Discussion started by: Meeran Rizvi
2 Replies

2. UNIX for Dummies Questions & Answers

All combinations from simple regex

Hi ! Before trying to write a code, is there any program or code that generates all the combinations of strings that simple awk regex can match. By "simple regex" I mean let's say without "+", "*", and with a limited number of characters (e.g. from "1" to "5"). e.g: input: 34?5 output:... (9 Replies)
Discussion started by: beca123456
9 Replies

3. Shell Programming and Scripting

grep -v and regex

How to match lines that don't contain a patern in regex it self, without using the -v option of grep? (15 Replies)
Discussion started by: vistastar
15 Replies

4. Shell Programming and Scripting

help with simple regex expression

I am trying to grep the following line in a file using a bash shell: (..) admin1::14959:::::: (..) It works with the following expression (as expected) # cat file | grep ^*:: admin1::14959:::::: but it does not work with (not expected) # cat /etc/shadow | grep ^+:: I assume the... (2 Replies)
Discussion started by: schms
2 Replies

5. UNIX for Dummies Questions & Answers

| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax

Hello, I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide. ls -aLl /bin | grep "\(x\)" Which works, just highlights 'x' where ever, when ever. I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies

6. Shell Programming and Scripting

Simple regex problem?

Hi all, I am looking to create words from a sentence which adhere to a custom search pattern from my website: Example: ! +! / += ~ where the terms ! = not, +! = AND NOT, += - and equals and ~ = can be like.... Now here is the issue...i want to split a sentence like the one above on... (1 Reply)
Discussion started by: muay_tb
1 Replies

7. Shell Programming and Scripting

Need Help with Simple Regex

I have got a question. How to do this? I mean AND expression in regex. List all the files in current directory that do not contain the words use AND take. Thx.:p (15 Replies)
Discussion started by: evilfreakz
15 Replies

8. Shell Programming and Scripting

A simple find and replace without using any regex (bash)

Hi, I need to do an exact find and replace (I don't want to use regular expressions because the input comes from user). I want to find a line that matches the user's input text and replace it with an empty string. For example, let's say the user enters I love "Unix" and the contents of the... (2 Replies)
Discussion started by: srikanths
2 Replies

9. UNIX for Dummies Questions & Answers

grep with Regex help!

Hello everybody, I'd like to know how is it I should write a regex in unix to match a string not followed by another string (anywhere in the line). To be more specific, I want to find lines where "drop table" is found, but not followed anywhere in the line by the character "&". For... (3 Replies)
Discussion started by: mvalonso
3 Replies

10. UNIX for Dummies Questions & Answers

use of regex on grep

having a look on the regex site I saw that characters can be search using hex values http://www.regular-expressions.info/characters.html So I try to use it whith grep to find a on a string (octal Decimal Hexa : 350 232 E8) but it doesn't work E.g. /usr/bin/echo '\0350' | egrep '\xE8' ... (0 Replies)
Discussion started by: solea
0 Replies

Featured Tech Videos