Using cat to match pattern start with particular date.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using cat to match pattern start with particular date.
# 1  
Old 12-08-2010
Using cat to match pattern start with particular date.

Hi All,

version :-
SunOS rdrsu1 5.10 Generic_142900-12 sun4u sparc SUNW,SPARC-Enterprise

I have a requirenemet, where I have to extrace eroror start with ORA-, which match a perticular date. In below text I only extract out error coming on wed-8 and start with text like "ORA-". hope you understand my problem.

Your support on this would be highy appriciated.


Code:
Thread 1 advanced to log sequence 94100
  Current log# 1 seq# 94100 mem# 0: /data/oracle/NYRDRSU1/redo01/NYRDRSU1_redo01a.dbf
  Current log# 1 seq# 94100 mem# 1: /data/oracle/NYRDRSU1/redo02/NYRDRSU1_redo01b.dbf
Wed Dec  8 14:27:41 2010
Thread 1 advanced to log sequence 94101
  Current log# 2 seq# 94101 mem# 0: /data/oracle/NYRDRSU1/redo01/NYRDRSU1_redo02a.dbf
  Current log# 2 seq# 94101 mem# 1: /data/oracle/NYRDRSU1/redo02/NYRDRSU1_redo02b.dbf
Wed Dec  8 14:29:26 2010
Thread 1 advanced to log sequence 94102
  Current log# 3 seq# 94102 mem# 0: /data/oracle/NYRDRSU1/redo01/NYRDRSU1_redo03a.dbf
  Current log# 3 seq# 94102 mem# 1: /data/oracle/NYRDRSU1/redo02/NYRDRSU1_redo03b.dbf
Wed Dec  8 14:30:55 2010
ORA-1688: unable to extend table SYS.WRH$_ACTIVE_SESSION_HISTORY partition WRH$_ACTIVE_2066121145_24657 by 128 in


hare krishna
# 2  
Old 12-08-2010
Like this?
Code:
sed -n '/Wed Dec  8.*2010/ N; /\nORA-/p' infile

Although I don't understand how cat fits into the issue.
# 3  
Old 12-08-2010
Maybe something like this?
Code:
$ awk '/ORA/{print s,$1}{s=$0}' file
Wed Dec  8 14:30:55 2010 ORA-1688:

# 4  
Old 12-08-2010
Thanks very much both of you, but I need something, which make more sense to me. like after your solution, the output resulted like below one. I want only unique values to display and the value must be displayed which has text associated with that like "ORA-1691: unable to extend". I hope you , I able to descibe my issue. Also let me know, if I can award you a point. on oracle forum, we have point system.




Code:
Tue Dec  7 07:44:28 2010 ORA-1653:
Tue Dec  7 07:44:28 2010 ORA-1653:
Tue Dec  7 07:44:28 2010 ORA-1653:
Tue Dec  7 07:44:28 2010 ORA-1653:
Tue Dec  7 07:44:28 2010 ORA-1653:
Tue Dec  7 07:44:28 2010 ORA-1653:
Tue Dec  7 07:44:28 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1653:
Tue Dec  7 07:44:29 2010 ORA-1691:
ORA-1691: unable to extend lobsegment TGSAPP_GC.SYS_LOB0001449144C00003$$ by 128 in tablespace              TGSAPP_DATA  ORA-

# 5  
Old 12-09-2010
Code:
nawk '(NF==5){x=($0~/Wed Dec  8/)?1:0}(x&&/ORA-/)' infile

or

Code:
# date
Thu Dec  9 18:56:14 CET 2010
# cat ts1
Thread 1 advanced to log sequence 94100
  Current log# 1 seq# 94100 mem# 0: /data/oracle/NYRDRSU1/redo01/NYRDRSU1_redo01a.dbf
  Current log# 1 seq# 94100 mem# 1: /data/oracle/NYRDRSU1/redo02/NYRDRSU1_redo01b.dbf
Wed Dec  8 14:27:41 2010
Thread 1 advanced to log sequence 94101
  Current log# 2 seq# 94101 mem# 0: /data/oracle/NYRDRSU1/redo01/NYRDRSU1_redo02a.dbf
  Current log# 2 seq# 94101 mem# 1: /data/oracle/NYRDRSU1/redo02/NYRDRSU1_redo02b.dbf
Wed Dec  8 14:29:26 2010
Thread 1 advanced to log sequence 94102
  Current log# 3 seq# 94102 mem# 0: /data/oracle/NYRDRSU1/redo01/NYRDRSU1_redo03a.dbf
  Current log# 3 seq# 94102 mem# 1: /data/oracle/NYRDRSU1/redo02/NYRDRSU1_redo03b.dbf
Thu Dec  9 14:30:55 2010
ORA-1688: unable to extend table SYS.WRH$_ACTIVE_SESSION_HISTORY partition WRH$_ACTIVE_2066121145_24657 by 128 in

Code:
# nawk '(NF==5){x=($0~/'"$(date | cut -c1-10)"'/)?1:0}(x&&/ORA-/)' ts1
ORA-1688: unable to extend table SYS.WRH$_ACTIVE_SESSION_HISTORY partition WRH$_ACTIVE_2066121145_24657 by 128 in

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies

2. Shell Programming and Scripting

Pattern to match date in YYYY-MM-DD format on Linux machine

Hi Expert, Request your help. For date validation in csv file, i have written below code for linux machine I want the date to be in format 2017-05-11(YYYY-MM-DD), if not present in this format the error should be printed. Could you please help in finding the right pattern to match above date... (8 Replies)
Discussion started by: as7951
8 Replies

3. Shell Programming and Scripting

sed Range Pattern and 2 lines before Start Pattern

Hi all, I have been searching all over Google but I am unable to find a solution for a particular result that I am trying to achieve. Consider the following input: 1 2 3 4 5 B4Srt1--Variable-0000 B4Srt2--Variable-1111 Srt 6 7 8 9 10 End (3 Replies)
Discussion started by: y2jacky
3 Replies

4. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

5. UNIX for Dummies Questions & Answers

Match Pattern after certain pattern and Print words next to Pattern

Hi experts , im new to Unix,AWK ,and im just not able to get this right. I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Discussion started by: 100bees
2 Replies

6. Shell Programming and Scripting

Match first pattern first then extract second pattern match

My input file: <accession>Q91G55</accession> <name>043L_IIV6</name> <protein> <recommendedName> <location> <position position="294"/> </location> <fullName>Uncharacterized protein 043L</fullName> <accession>P18556</accession> <name>1106L_ASFB7</name> <protein> <recommendedName>... (5 Replies)
Discussion started by: patrick87
5 Replies

7. UNIX for Dummies Questions & Answers

Lynx Grep Pattern Match 2 conditions Print from Start to End

I am working on a scraping project and I am stuck at this tiny grep pattern match. Sample text : FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. FPA List. ABC Personal Planning Catherine K. Wat Cath Wat Catherine K. Wat Catherine K. Wat IFRAME:... (8 Replies)
Discussion started by: kkiran
8 Replies

8. Shell Programming and Scripting

Date Pattern Match (replacement string)

Hello, i am splitting files and sometimes the string of the pattern doesnt exist in the input file it starts for example with 00:00:01. So the output is completely desorganized, is there any way of putting a replacement string in the pattern so it will grab all the times from 00:**:** to first... (0 Replies)
Discussion started by: x-plicit78
0 Replies

9. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

10. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies
Login or Register to Ask a Question