Sponsored Content
Top Forums Shell Programming and Scripting How to cut specific line and one line under? Post 302423057 by nir_s on Thursday 20th of May 2010 05:15:59 AM
Old 05-20-2010
How to cut specific line and one line under?

Hi guys,

I need to analyze the following alert log file:
Code:
Beginning log switch checkpoint up to RBA [0x4243f.2.10], SCN: 3916025539605
Sat May  1 00:54:52 2010
Thread 1 advanced to log sequence 271423 (LGWR switch)
  Current log# 1 seq# 271423 mem# 0: /dw/stg_redo01/log_dwstg_g1_m1.log
  Current log# 1 seq# 271423 mem# 1: /dw/stg_redo02/log_dwstg_g1_m2.log
Sat May  1 00:54:56 2010
Completed checkpoint up to RBA [0x4243f.2.10], SCN: 3916025539605
Sat May  1 00:57:40 2010
Beginning log switch checkpoint up to RBA [0x42440.2.10], SCN: 3916026109591
Sat May  1 00:57:40 2010
Thread 1 advanced to log sequence 271424 (LGWR switch)
  Current log# 4 seq# 271424 mem# 0: /dw/stg_redo01/log_dwstg_g4_m1.log
  Current log# 4 seq# 271424 mem# 1: /dw/stg_redo02/log_dwstg_g4_m2.log
Sat May  1 00:57:52 2010
Completed checkpoint up to RBA [0x42440.2.10], SCN: 3916026109591

From this file I need to cut the lines that beginning with "Beginning log switch checkpoint up to RBA" and every line under this line which reflect the time stamp.
The final file should be as the following:
Code:
Beginning log switch checkpoint up to RBA [0x42428.2.10], SCN: 3916022809348
Sat May  1 00:00:29 2010
Beginning log switch checkpoint up to RBA [0x42429.2.10], SCN: 3916022929579
Sat May  1 00:02:52 2010
Beginning log switch checkpoint up to RBA [0x4242a.2.10], SCN: 3916022993393
Sat May  1 00:04:12 2010
...

How to do it with sed command?

Thanks in advance,
Nir
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting Characters at specific position in a line if the line is certain length

I've got a file that would have lines similar to: 12345678 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 23456781 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 34567812 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 45678123 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 xx.00... (10 Replies)
Discussion started by: Cailet
10 Replies

2. Shell Programming and Scripting

To cut a specific line

Hi, I need to remove a specific line from a file.. For eg: From the html codings, I need to find the word "iframe frameborder" and cut it . I tried with find . -type f -exec grep -H 'iframe frameborder' {} \; > <filename> From the output of this result, I need to remove the "iframe... (14 Replies)
Discussion started by: gsiva
14 Replies

3. Shell Programming and Scripting

cut a string in a textfile line per line

i need to cut the string in a textfile but each line has a specific way of cutting it (different lengths) i have a for loop that gets the string line per line, then each line has to be compared: for x in `cat tmp2.txt`; do if; then echo 'BAC' elif ... (6 Replies)
Discussion started by: izuma
6 Replies

4. Shell Programming and Scripting

How to cut first line only from a text near a specific column without cutting a word

First I have to say thank you to this community and this forum. You helped me very much builing several useful scripts. Now, I can't get a solution the following problem, I'm stuck somehow. Maybe someone has an idea. In short, I dump a site via lynx and pipe the output in a file. I need to... (7 Replies)
Discussion started by: lowmaster
7 Replies

5. Shell Programming and Scripting

Using awk to read a specific line and a specific field on that line.

Say the input was as follows: Brat 20 x 1000 32rf Pour 15 p 1621 05pr Dart 10 z 1111 22xx My program prompts for an input, what I want is to use the input to locate a specific field. Like if I type in, "Pou" then it would return "Pour" and just "Pour" I currently have this line but it is... (6 Replies)
Discussion started by: Bungkai
6 Replies

6. Shell Programming and Scripting

sed or awk, cut, to extract specific data from line

Hi guys, I have been trying to do this, but... no luck so maybe you can help me. I have a line like this: Total Handled, Received, on queue Input Mgs: 140 / 14 => 0 I need to, get the number after the / until the =, to get only 14 . Any help is greatly appreciated. Thanks, (4 Replies)
Discussion started by: ocramas
4 Replies

7. Shell Programming and Scripting

Commenting a specific line and inserting a new line after commented line.

Hello All, I have following file contents cat file #line=aaaaaa #line=bbbbbb #line=cccccc #line=dddddd line=eeeeee #comment=11111 #comment=22222 #comment=33333 #comment=44444 comment=55555 Testing script Good Luck! I would like to comment line line=eeeeee and insert a new line... (19 Replies)
Discussion started by: manishdivs
19 Replies

8. Shell Programming and Scripting

Cut from specific line number to a line number

Hi All, I've a file like this.. Sheet1 a,1 a,2 a,3 a,4 a,5 Sheet2 a,6 a,7 a,8 a,9 a,10 Sheet3 a,11 a,12 a,13 (7 Replies)
Discussion started by: manab86
7 Replies

9. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

10. Shell Programming and Scripting

Need to cut a specific pattern from a line

Hello, I need to cut a specific pattern from a line irrespecitve of knowing field place. I am aware to cut field if you know the place of the field, but for me The sting place varies. 1468129514436,0,something_error,Non HTTP response code: java.net.URISyntaxException,Non HTTP response... (5 Replies)
Discussion started by: mirwasim
5 Replies
LOGTOP(1)						      General Commands Manual							 LOGTOP(1)

NAME
logtop - Realtime log line rate analyser SYNOPSIS
logtop [OPTIONS] DESCRIPTION
logtop is a System Administrator tool analyzing line rate on stdin. It reads on stdin and print a constantly updated result displaying, in columns: Line number, count, frequency, and the actual line. $ tail -f FILE | logtop is the friendly version of: $ watch 'tail FILE | sort | uniq -c | sort -gr' OPTIONS
-s, --size=K Only keep K lines in memory, instead of 10000. -q, --quiet Do not display a live view of the data, only display a top at exit. -l, --line-by-line=K Print result line by line, in a machine friendly format, K is the number of result to print per line. Line by line format is : [%d %f %s ]* %d : Number of occurences %f : Frequency of apparition %s : String (Control chars replaced by dots. -i, --interval=K Interval between graphical updates, in seconds. Defaults to 1. -h, --help Show summary of options. -v, --version Show version of program. EXAMPLES
Here are some logtop usage examples. tail -f cache.log | grep -o "HIT|MISS" | logtop Realtime hit / miss ratio on some caching software log file. tail -f access.log | cut -d' ' -f1 | logtop -s 10000 Realtime most querying IPs on your server, as long as log lines in access.log starts with the client IP. tail -f access.log | cut -d' ' -f7 | logtop -s 10000 Realtime most requested web pages in a NCSA like log file. cat auth.log | grep -v "CRON" | grep -o ": .*" | logtop -q -s 100000 Display a one-shot simple analyse of your auth.log. SEE ALSO
watch(1) AUTHOR
logtop was written by Julien Palard. This manual page was written by Julien Palard <julien@palard.fr>, for the Debian project (and may be used by others). April 16, 2011 LOGTOP(1)
All times are GMT -4. The time now is 08:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy