grep problem

SQL*Plus: Release 9.2.0.8.0 - Production on Mon Jul 21 07:53:35 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning option
JServer Release 9.2.0.8.0 - Production

SQL> SQL> USER is "CCOD"
SQL> cREATE TABLE HELLOEVERY (DEF VARCHAR2(40))
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning option
JServer Release 9.2.0.8.0 - Production
SQL*Plus: Release 9.2.0.8.0 - Production on Mon Jul 21 07:53:35 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning option
JServer Release 9.2.0.8.0 - Production

SQL> SQL> USER is "CCOD"
SQL> cREATE TABLE greatwork(abcVARCHAR2(40))
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
With the Partitioning option
JServer Release 9.2.0.8.0 - Production

i just want to have
SQL> cREATE TABLE HELLOEVERY (DEF VARCHAR2(40))
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

SQL> cREATE TABLE greatwork(abcVARCHAR2(40))
*
ERROR at line 1:
ORA-00955: name is already used by an existing object

there could be repeated pattern as well.

is there any way to grep only 3 or 4 lines after grepping a pattern

please help

thanks

Not grep, but an example with sed:

root@isau02:/data/tmp/testfeld> cat infile
ID .... VALUE
A001 .... 100
B002 .... 200
A004 .... 300
B006 .... 100
A997 .... 200
B776 .... 400
root@isau02:/data/tmp/testfeld> sed -n '/B002/ {p;n;p;n;p}' infile
B002 .... 200
A004 .... 300
B006 .... 100

Please use [ c o d e ] and [ / c o d e ] tags when displaying code or output from logs/errors etc., ty :slight_smile:

It is unclear what you are trying to look for. However, sometimes a file can be re-formatted to combine multiple related lines into one - so grep can work - and then the file broken back into pieces.

This is done with a "tr" command.

If you provide more on what you are trying to learn from this file, someone may be able to assist in extracting the information.

With grep you can simply print 2 lines before and 1 line after the pattern as follow:

 grep -B 2 -A 1 '^ERROR at line' file

Regards