Sponsored Content
Top Forums Shell Programming and Scripting delete rows between closest pattern or range Post 302388625 by sudheer1984 on Thursday 21st of January 2010 03:29:20 AM
Old 01-21-2010
delete rows between closest pattern or range

Hi

I am having some problom deleting the lines between two specific lines in a file. need to delete lines between two closest lines. i.e need to find the closest range or pattern in a file with repeating patterns.

Sample Input:
Code:
 
WARNING
<some text in n number of lines>
ERROR:2597
WARNING
<some text in n number of lines>
ERROR:0000
WARNING
<some text in n number of lines>
ERROR:4578
WARNING
<some text in n number of lines>
ERROR:1344
WARNING
<some text in n number of lines>
ERROR:0000
WARNING
<some text in n number of lines>
ERROR:3456

Now, need to delete the lines which has error number 0000. i.e delete the range from WARNING to ERROR:0000. problom here is to find the closest range between WARNING and ERROR:0000

Sample Output:

Code:
 
WARNING
<some text in n number of lines>
ERROR:2597
WARNING
<some text in n number of lines>
ERROR:4578
WARNING
<some text in n number of lines>
ERROR:1344
WARNING
<some text in n number of lines>
ERROR:3456

I tried this, but its matching the widest pattern

Code:
 
sed '/WARNING/,/ERROR:0000/ d' filename

Please help me with this.
Thanks
Sudheer.

Last edited by zaxxon; 01-21-2010 at 05:28 AM.. Reason: Also use code tags for your logs please, ty.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk or sed for finding closest pattern to a line number

hi guys, I want to do pattern matching with awk or sed but I don't know how. here's what I want: I have a line number for a pattern that I have already found using grep, and I know a pattern like "---" that happens a few lines above that certain line number. I want to print out the chunk... (1 Reply)
Discussion started by: alirezan
1 Replies

2. Shell Programming and Scripting

print range between two patterns if it contains a pattern within the range

I want to print between the range two patterns if a particular pattern is present in between the two patterns. I am new to Unix. Any help would be greatly appreciated. e.g. Pattern1 Bombay Calcutta Delhi Pattern2 Pattern1 Patna Madras Gwalior Delhi Pattern2 Pattern1... (2 Replies)
Discussion started by: joyan321
2 Replies

3. UNIX for Advanced & Expert Users

sed match closest/nearest pattern

All i am struggling to raplace some text in a line between two (closest) patterns , line="/home/usr/bin/:/home/usr/devuser,n1.9/bin:/home/usr/root/bin" i want to replace "devuser,n1.9" with "NEWVAL", basically all teh text from "devuser" until nearest '/' with some new text. i tried teh... (1 Reply)
Discussion started by: sudheer1984
1 Replies

4. Shell Programming and Scripting

Closest Number from a Range of Numbers

out of a range of numbers, how can i pick out the number that is the closest to any arbitrary/random number that a user supplies? say the range of numbers are between 1 - 90000. but that doesn't mean each number exist between 1 - 90000. the range of numbers could be for example: 1, 3, 4, 6,... (6 Replies)
Discussion started by: SkySmart
6 Replies

5. UNIX for Dummies Questions & Answers

Extracting rows from a text file if the value of a column falls between a certain range

Hi, I have a file that looks like the following: 10 100080417 rs7915867 ILMN_1343295 12 6243093 7747537 10 100190264 rs2296431 ILMN_1343295 12 6643093 6647537 10 100719451 SNP94374 ILMN_1343295 12 6688093 7599537 ... (1 Reply)
Discussion started by: evelibertine
1 Replies

6. UNIX for Dummies Questions & Answers

Awk: how to copy a range of rows in GAMS environment

Hi I have a problem in using awk in GAMS. I have to copy a part of a .txt file selecting the rows between these two lines "0 / END OF TRANSFORMER DATA, BEGIN AREA DATA" "0 / END OF AREA DATA, BEGIN TWO-TERMINAL DC DATA" I thought of using a command like this: $onecho > area.awk... (4 Replies)
Discussion started by: Pintug
4 Replies

7. Shell Programming and Scripting

Sum of range of rows and columns in matrix

Hi all, I have a large matrix of 720 x 25. I want to get sum of range of rows and columns. Like, I need sum of all columns and row number 2 to 21, then leaving 22nd row, again sum of all columns and row number 23 to 42 again leaving 43rd row and then sum of 44th to 63. Means I want to add all... (4 Replies)
Discussion started by: CAch
4 Replies

8. Shell Programming and Scripting

Printing rows based on column range

Hello, I have a file with nearly 57K lines. I want to filter the lines based on the range of values in a column. For e.g. print lines whose 3rd filed is >=0.02. Input file: LOC_Os09g32030 LOC_Os02g18880 0.0200037219149773 undirected NA NA LOC_Os03g58630 LOC_Os09g35690 ... (1 Reply)
Discussion started by: Sanchari
1 Replies

9. Shell Programming and Scripting

Concatenate rows and redefine range

I'm trying to find a way to concatenate consecutive rows (key is column $1 and $2) if column $5 an $6 are integers and redefine ranges in columns $3&$4 and $5&$6 Unfortunately I'm still learning the very basics so I cannot figure a way of doing this with awk. Input file 15 30 21 21 25.0... (11 Replies)
Discussion started by: alex2005
11 Replies

10. 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
lptest(1B)					     SunOS/BSD Compatibility Package Commands						lptest(1B)

NAME
lptest - generate line printer ripple pattern SYNOPSIS
/usr/ucb/lptest [ length [count]] DESCRIPTION
The lptest utility writes the traditional ripple test pattern to the standard output. In 96 lines, the ripple test pattern prints all 96 printable ASCII characters in each position. The ripple test pattern was originally created to test printers. It is also useful for test- ing terminals, driving terminal ports, debugging, and performing tasks that require a quick supply of random data. This command is obsolete. OPTIONS
length Specifies the length of the output line in characters. 79 characters is the default. count Specifies the number of output lines. 200 lines is the default. If count is specified, length must also be specified. EXIT STATUS
The following exit values are returned: 0 Successful completion. non-zero An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscplp | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.10 9 Sep 1996 lptest(1B)
All times are GMT -4. The time now is 10:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy