Hi,
Suppose I have the following text in a file.
ORA-00942: table or view does not exist
ORA-01555: snapshot too old: rollback segment number string with name "string"
too small
Is there any way I can list all the text that starts only with 'ORA-'?
Or there any grep command that can pull out only 'ORA-xxxxx'? Having X as any number.
Please help.
thanks.
$ grep '^ORA-[0-9]\{5\}:' inputfile
Cheers
ZB
Ygor
January 9, 2007, 10:02pm
3
Try...
awk 'match($0,"ORA-....."){print substr($0,RSTART,RLENGTH)}' file1
ZB,
I tried your suggestion but it still gives me the whole string, not the ORA-00942 text.
Ygor,
I have to replace a valid number to RSTART and RLENGTH right?
I tried to run the command it gives me a syntax error/bailing out
thanks
Ygor
January 9, 2007, 11:38pm
6
No, RSTART and RLENGTH are awk built-ins which are set by the match function.
On Solaris, try nawk, otherwise post your error message.
kakashi_jet:
Hi,
Suppose I have the following text in a file.
ORA-00942: table or view does not exist
ORA-01555: snapshot too old: rollback segment number string with name "string"
too small
Is there any way I can list all the text that starts only with 'ORA-'?
Or there any grep command that can pull out only 'ORA-xxxxx'? Having X as any number.
Please help.
thanks.
hi try out this
grep "^ORA\-\[1\-9\]\{5\}" filename
kakashi_jet:
Hi,
Suppose I have the following text in a file.
ORA-00942: table or view does not exist
ORA-01555: snapshot too old: rollback segment number string with name "string"
too small
Is there any way I can list all the text that starts only with 'ORA-'?
Or there any grep command that can pull out only 'ORA-xxxxx'? Having X as any number.
Please help.
thanks.
If you have Python, this is an alternative:
#!/usr/bin/python
for line in open("textfile"):
if line.startswith("ORA"):
print line
or
python -c "print ''.join([line for line in open('file') if line.startswith('ORA')])"