egrep problem | printing next line?????


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting egrep problem | printing next line?????
# 1  
Old 06-23-2008
egrep problem | printing next line?????

Hi !!! Dear People,
Please help me with the following problem.
consider this output:
Top 5 Timed Events
~~~~~~~~~~~~ Total
Event Waits Time (s) Ela Time
---------------------------- ------------ ----------- -----
CPU time 2,152 54.10
free buffer 7,059 641 16.10
control file parallel write 19,625 490 12.31
log file sync 7,010 217 5.44
db file sequential read 3,000 1000 .99
--------------------------------------------------------
we all know ,if i give
egrep '^(log file sync)...' /oracle/user_user/2
it will print
log file sync 7,010 217 5.44
please tel me how to print next line using egrep.
meaning... it should print immediate next line of pattern matching character(here it's log file sync).
my desired output should be
db file sequential read 3,000 1000 .99

perhaps with the same pattern matching character

please help me to give the command.
im using default shell(-sh)

Thanks in Advance
# 2  
Old 06-23-2008
Line before is "-B", "line after" is "-A". One line after is "-A1", see 'man grep'.
If you want to see only the next line you could pipe that through 'tac|head -1'.
# 3  
Old 06-24-2008
hay it's not working.. please give me full code......
# 4  
Old 06-24-2008
Code:
awk '/^log file sync/{getline;print;exit}' file

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Egrep problem

Hi everyone, Can someone look this over? find /oracle/diag/rdbms/*/*/trace -type f -name '*d00*.trc' -mtime 0 \ -exec egrep -c 'TNS-12535: TNS:operation timed out' '{}' '+' | awk -F: '{print $1}' | egrep -c '2015-01-22' usidp/trace/abcdef_d001_21751.trc:9 \... (1 Reply)
Discussion started by: bdby
1 Replies

2. Shell Programming and Scripting

Problem with egrep and cat

Hello, I want to find some keywords in a dd image. I have created a keyword file (1.txt) and search the dd image using, cat /media/sdb1/test/c.dd.001 | strings | egrep -i --color -f 1.txt It works, But how can I get the file name and path? Many thanks. (7 Replies)
Discussion started by: yzy9951
7 Replies

3. Shell Programming and Scripting

egrep line with perfect mach

Hi Input File A L006 AL01 0 (OCK) L006 A006 0 (OCK) L011 AR11 1 (NLOCK) Input File B L006 AL01 0 (OCK) L006 A006 0 (OCK) Need Egrep Command for perfect Match Thanks (4 Replies)
Discussion started by: asavaliya
4 Replies

4. UNIX for Dummies Questions & Answers

egrep line which begging with

HI Guys, I want egrep from ./txt file which begging from Hello. File A.txt Hello A Abc Abc Xyz Hello B Hello C .. ... Output File B Hello A Hello B (2 Replies)
Discussion started by: asavaliya
2 Replies

5. Shell Programming and Scripting

egrep 4th line from match

Can some one help me to print 4th line before the match using egrep or grep command options. i have a very large file and i need to search the entire file, look for the match (key word) and print 4th line before the matched key word. (9 Replies)
Discussion started by: ramana117
9 Replies

6. Shell Programming and Scripting

egrep output each file in new line

I have the following script that searches in several files and shows the search results and the matches filename on the screen. find . -exec egrep -wH "word1|word2" {} \; the output from the search display as: file1 word1 word2 I need to show each file search output result on new... (5 Replies)
Discussion started by: konddor
5 Replies

7. Shell Programming and Scripting

Problem using egrep: spaces and newline

Hello: I am working in bash and am a newbie. I want to eliminate spaces from strings. Since this is a basic operation, I searched online and implemented the suggestions; however, I am facing a problem here. I have an input file which looks like this: abc defghi jklmno pqrs tuvw xyzabcd... (8 Replies)
Discussion started by: andyu11
8 Replies

8. Shell Programming and Scripting

egrep problem

Hello Experts, I am trying to parse a gz file like this gzip -cd filename | xargs egrep -h -e '.*somepattern</TAG>' | grep -c '<TAG2>`date '+%Y-%m-%d'`</TAG2>' But I am getting an error : egrep cant open. Any ideas fellas? (1 Reply)
Discussion started by: King Nothing
1 Replies

9. Shell Programming and Scripting

egrep understanding problem

Hi, Can anyone please let me know the meaning of this line,i am not able to understand the egrep part(egrep '^{1,2}).This will search for this combination in beginning but what does the values in {}signifies here. /bin/echo $WhenToRun | egrep '^{1,2}:$' >/dev/null (1 Reply)
Discussion started by: namishtiwari
1 Replies

10. UNIX for Dummies Questions & Answers

adding blank line in egrep

I followed the egrep example given in the thread "parse text or complex grep ?". It is exactly what I need...except... how do I insert a blank line after the second line? My exact command is: egrep 'patt1|patt2' filename the result is: patt1 patt2 patt1 patt2 and so on. I would... (2 Replies)
Discussion started by: antalexi
2 Replies
Login or Register to Ask a Question