Need to cut a some required data from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to cut a some required data from file
# 1  
Old 01-10-2013
Need to cut a some required data from file

Data_Consolidation_Engine_Part_2_Job2..TgtArBkt: ORA-00942: table or view does not exist

I have some thing like above in the file..

Upto this portion Data_Consolidation_Engine_Part_2_Job2..TgtArBkt: the length can be vary ..

Can some one help me in taking this portion alone ORA-00942: table or view does not exist
# 2  
Old 01-10-2013
Code:
awk '/ORA-/{match($0,"ORA-");print substr($0,RSTART);}' file

OR
Code:
awk '/ORA-/{match($0,/ORA-[0-9]/);print substr($0,RSTART);}' file

# 3  
Old 01-10-2013
I tried some thing like this

Code:
dsjob -logsum -type WARNING -max 2 AvpnMgr Data_Consolidation_Engine_Part_2_Job2|grep "ORA"|awk '/ORA-/{match($0,/ORA-[0-9]/);print substr($0,RSTART);}'

Its not working for me ..Giving me some syntax error

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.
# 4  
Old 01-10-2013
First of all remove that grep because we are covering that part in the awk program. If you are on SunOS or Solaris then use nawk or /usr/xpg4/bin/awk instead.

OR use sed
Code:
sed 's/.*\(ORA-\)/\1/p' file

# 5  
Old 01-10-2013
Thanks a lot ..Its working fine.

Also can you please help me in ORA-00942(...) cutting this one to ORA-00942
# 6  
Old 01-10-2013
Code:
sed 's/.*\(ORA-[0-9]*\).*/\1/p' file

# 7  
Old 01-10-2013
Code:
cat -n file | grep -w  2 | cut -d ":" -f2 | tr -d ' '|cut -d "=" -f2|sed 's/.*\(ORA-[0-9]*\).*/\1/p'

its working fine but the thing is that it is repeating twice '

ORA-00942
ORA-00942 like this

Last edited by Scott; 01-10-2013 at 02:14 PM.. Reason: Code tags. Last reminder.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut and paste data in new file

HI Guys, I have file A: Abc XyZ Abc Xyz Kal Kaloo Abc XyZ Abc Xyz Kalpooo Abc XyZ Abc Xyz Kloo Abc Abc Klooo I want file B Abc XyZ Abc Xyz Kal Kaloo Abc XyZ Abc Xyz Kalpooo Abc XyZ Abc Xyz Kloo File A is now 1 lines Abc Abc Klooo Cut all lines which have xyz... (2 Replies)
Discussion started by: asavaliya
2 Replies

2. Shell Programming and Scripting

Help required the cut the whole contents from one file and paste it into new file

Hi, First of all sincere apologies if I have posted in a wrong section ! Please correct me if I am wrong ! I am very new to UNIX scripting. Currently my problem is that I have a code file at the location /home/usr/workarea/GeneratedLogs.log :- Code :- (Feb 7, 571 7:07:29 AM),... (4 Replies)
Discussion started by: acidburn_007
4 Replies

3. Shell Programming and Scripting

How to cut data from file and create another file.

I have file which has more than 1000 lines. PFB file info Line 1. <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance"... (8 Replies)
Discussion started by: humaemo
8 Replies

4. Shell Programming and Scripting

How to filter required data from file using bash script?

Hi All , I have one file like below , Owner name = abu2-kxy-m29.hegen.app Item_id = AX1981, special_id = *NULL*, version = 1 Created = 09/01/2010 12:56:56 (1283389016) Enddate = 03/31/2011 00:00:00 (1301554800) From the above file I need to get the output in the below format ,i need... (3 Replies)
Discussion started by: gnanasekar_beem
3 Replies

5. Shell Programming and Scripting

How to cut some data from big file

How to cut data from big file my file around 30 gb I tried "head -50022172 filename > newfile.txt ,and tail -5454283 newfile.txt. It's slowy. afer that I tried sed -n '46467831,50022172p' filename > newfile.txt ,also slow Please recommend me , faster command to cut some data from... (4 Replies)
Discussion started by: almanto
4 Replies

6. UNIX for Dummies Questions & Answers

How to cut data block from .txt file in shell scripting

Hi All, Currently i have to write a script. For which i need to cut a block from .txt file. I know the specific word that starts the block and ends the block. Can we do it in shell scripting..? Please suggest.... (6 Replies)
Discussion started by: pank29
6 Replies

7. Shell Programming and Scripting

Help required with a Csh script to read data from a file

Dears, This is what i want.. I need to read a comma separated text file whose name is config.txt. whose content is like ; bscnara,btserrr bscsana,btssanacity ..... i need to read the first string and second string and use it to execute a another shell script. This is the logic. ... (1 Reply)
Discussion started by: fizzme
1 Replies

8. Shell Programming and Scripting

Need to read data from a file (cut/awk)

Hi list, i have an orcale spool file with SQL> select COMPMAP as SVC, ITEM, UNIT, sum(JAN), sum(FEB) SVC ITE U SUM(JAN) SUM(FEB) ------ --- - ---------- ---------- 401500 IOC Q 14 14 406200 LC Q 1 1 410124 IOC Q 5 4 410124 LC... (1 Reply)
Discussion started by: rejirajraghav
1 Replies

9. Shell Programming and Scripting

Help required using cut command

Hi all, I have one text as '/home/psv/file/test.ksh'. In that I want to cut the text as '/home/psv/file/' . Let me know which command to use. Thanks Mahalakshmi.A (4 Replies)
Discussion started by: mahalakshmi
4 Replies

10. Shell Programming and Scripting

help required with cut -d

i have a file in which data is like this 12 34 56 78 78 56 34 12 now i want to cut 2nd last column.... if 2nd column from start is to be cut then i can write cut -d" " -f2 filename what to do if 2nd column from end is to be cut ! any help thanks Sidhu (4 Replies)
Discussion started by: Amardeep
4 Replies
Login or Register to Ask a Question