Sponsored Content
Top Forums Shell Programming and Scripting delete rows between closest pattern or range Post 302388644 by ni2 on Thursday 21st of January 2010 04:35:33 AM
Old 01-21-2010
How about you look for lines that do not have ERROR.OOO

Code:
$cat file1
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

Code:
$  grep --before-context=2 -e "ERROR.[1-9][0-9]\+" file1
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 dont think this ^^^ is the fastest solution. While someone gives you something better.
 

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
Log::Report::Util(3pm)					User Contributed Perl Documentation				    Log::Report::Util(3pm)

NAME
Log::Report::Util - helpful routines to Log::Report INHERITANCE
Log::Report::Util is a Exporter DESCRIPTION
This module collects a few functions and definitions which are shared between different components in the Log::Report infrastructure. FUNCTIONS
escape_chars(STRING) Replace all escape characters into their readable counterpart. For instance, a new-line is replaced by backslash-n. expand_reasons(REASONS) Returns a sub-set of all existing message reason labels, based on the content REASONS string. The following rules apply: REASONS = BLOCK [ ',' BLOCKS] BLOCK = '-' TO | FROM '-' TO | ONE | SOURCE FROM,TO,ONE = 'TRACE' | 'ASSERT' | ,,, | 'PANIC' SOURCE = 'USER' | 'PROGRAM' | 'SYSTEM' | 'ALL' The SOURCE specification group all reasons which are usually related to the problem: report about problems caused by the user, reported by the program, or with system interaction. example: of expended REASONS WARNING-FAULT # == WARNING,MISTAKE,ERROR,FAULT -INFO # == TRACE-INFO ALERT- # == ALERT,FAILURE,PANIC USER # == MISTAKE,ERROR ALL # == TRACE-PANIC parse_locale(STRING) Decompose a locale string. For simplicity of the caller's code, the capatization of the returned fields is standardized to the preferred, although the match is case- insensitive as required by the RFC. The territory in returned in capitals (ISO3166), the language is lower-case (ISO639), the script as upper-case first, the character-set as lower-case, and the modifier and variant unchanged. In LIST context, four elements are returned: language, territory, character-set (codeset), and modifier. Those four are important for the usual unix translationg infrastructure. Only the "country" is obligatory, the others can be "undef". It may also return "C" and "POSIX". In SCALAR context, a HASH is returned which can contain more information: language, script, territory, variant, codeset, and modifiers. The variant (RFC3066 is probably never used) unescape_chars(STRING) Replace all backslash-something escapes by their escape character. For instance, backslash-t is replaced by a tab character. SYNOPSYS
my ($language, $territory, $charset, $modifier) = parse_locale 'nl_BE.utf-8@home'; my @take = expand_reasons 'INFO-ERROR,PANIC'; SEE ALSO
This module is part of Log-Report distribution version 0.94, built on August 23, 2011. Website: http://perl.overmeer.net/log-report/ LICENSE
Copyrights 2007-2011 by Mark Overmeer. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2011-08-23 Log::Report::Util(3pm)
All times are GMT -4. The time now is 05:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy