Sponsored Content
Top Forums Shell Programming and Scripting a better way to grep until end of error message, although most seem to be 1 or 2 line Post 302314090 by durden_tyler on Thursday 7th of May 2009 10:54:44 AM
Old 05-07-2009
Quote:
Originally Posted by VGR
...
Basically I want to capture the description of the error along with the error and count how many times it occurred.
...
[blank line] <-all the information upto this blank line and then how many times it appears in the file
Here's one way to do it:

Code:
$
$ cat input.txt
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
 
SQL0204N "ITUAM.VW_TT_VALUES" is an undefined name. 
SQLSTATE=42704
blah blah blah....
 
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
 
SQL0204N "ITUAM.VW_TT_VALUES_2" is an undefined name. 
SQLSTATE=42705
blah blah blah....
 
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
 
SQL0204N "ITUAM.VW_TT_VALUES_3" is an undefined name. 
SQLSTATE=42706
blah blah blah....
 
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned: success
$
$ perl -ne '{$n++ if /SQL\d{4}[A-Z].*/s}END{print "The error occurred $n times.\n"}' input.txt
The error occurred 3 times.
$
$

HTH,
tyler_durden
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep error message

hi, I get this error message after I pipe a lot of output into grep. Does anyone know what his means? grep: writing output: Invalid argument thanks, gammaman (3 Replies)
Discussion started by: gammaman
3 Replies

2. Solaris

syntax error at line 59: `end of file' unexpected

Hello... I'm trying to run the sshd script, but I keep geting the Syntax errot message . Here's the last few lines on the script. set nu in vi shows 58 lines, but I keep getting error referring to line 59. Any help is appreciated. Thanks, Remi else echo... (4 Replies)
Discussion started by: Remi
4 Replies

3. UNIX for Advanced & Expert Users

Is there a better way to grep until end of error message?

My file creates an output log after which includes a few sql queries. I segregate them into warnings and errors and then get a total count. The errors' and warnings' lines always start with SQL{4} followed by the details of the error. This is what im doing as o now... errors=`grep -A 1 -E... (1 Reply)
Discussion started by: VGR
1 Replies

4. Shell Programming and Scripting

Grep from a starting line till the end of the file

Hi Folks, I got to know from this forums on how to grep from a particular line say line 6 awk 'NR==6 {print;exit}' But how do i grep from line 6 till the end of the file or command output. Thanks, (3 Replies)
Discussion started by: Mr. Zer0
3 Replies

5. Shell Programming and Scripting

AWK-grep from line number to the end of file

Does anyone know how to use awk to act like grep from a particular line number to the end of file? I am using Solaris 10 and I don't have any GNU products installed. Say I want to print all occurrences of red starting at line 3 to the end of file. EXAMPLE FILE: red green red red... (1 Reply)
Discussion started by: thibodc
1 Replies

6. Homework & Coursework Questions

end of line error

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: #/bin/sh -xv #Author: Lauren Buecker #Date: September 28 2012 #Class COP3353 #Assignment: Assignment 4... (7 Replies)
Discussion started by: swimmerbhs
7 Replies

7. UNIX for Dummies Questions & Answers

Grep lines with numbers greater than 2 digits at the end of the line

I'm trying to grep lines where the digits at the end of each line are greater than digits. Tried this but it will only allow me to specify 2 digits. Any ideas would greatly be appreciated. grep -i '\<\{3,4,5\}\>' file ---------- Post updated at 05:58 PM ---------- Previous update was at 05:41... (1 Reply)
Discussion started by: jimmyf
1 Replies

8. Shell Programming and Scripting

Grep start and end line of each segments in a file

Cat file1 -------- ---------- SCHEMA.TABLE1 insert------- update----- ------------- ---------- SCHEMA.TABLE2 insert------- update----- ----------- ------------ SCHEMA.TABLE3 insert------- update----- ------------ grep -n SCHEMA > header_file2.txt (2 Replies)
Discussion started by: Veera_V
2 Replies

9. SCO

Grep to ignore suffix & find end of line

In COBOL, a hyphen can be used in a field name and in a specific program some field names would be identical to others except a suffix was added--sometimes a suffix to a suffix was used. For example, assume I am looking for AAA, AAA-BBB, and AAA-BBB-CCC and don't want to look at AAA-BBB-CCC... (7 Replies)
Discussion started by: wbport
7 Replies

10. Shell Programming and Scripting

Grep after - til the end of the line

Hi, i need to cat a file after # till the end of the file usually ill do cat /etc/somthing | grep -A999999 # but its not that professional thanks edit by bakunin: please use CODE-tags (or ICODE-tags) for code and data. Thank you. (9 Replies)
Discussion started by: batchenr
9 Replies
warnings(3pm)						 Perl Programmers Reference Guide					     warnings(3pm)

NAME
warnings - Perl pragma to control optional warnings SYNOPSIS
use warnings; no warnings; use warnings "all"; no warnings "all"; use warnings::register; if (warnings::enabled()) { warnings::warn("some warning"); } if (warnings::enabled("void")) { warnings::warn("void", "some warning"); } if (warnings::enabled($object)) { warnings::warn($object, "some warning"); } warnings::warnif("some warning"); warnings::warnif("void", "some warning"); warnings::warnif($object, "some warning"); DESCRIPTION
The "warnings" pragma is a replacement for the command line flag "-w", but the pragma is limited to the enclosing block, while the flag is global. See perllexwarn for more information and the list of built-in warning categories. If no import list is supplied, all possible warnings are either enabled or disabled. A number of functions are provided to assist module authors. use warnings::register Creates a new warnings category with the same name as the package where the call to the pragma is used. warnings::enabled() Use the warnings category with the same name as the current package. Return TRUE if that warnings category is enabled in the calling module. Otherwise returns FALSE. warnings::enabled($category) Return TRUE if the warnings category, $category, is enabled in the calling module. Otherwise returns FALSE. warnings::enabled($object) Use the name of the class for the object reference, $object, as the warnings category. Return TRUE if that warnings category is enabled in the first scope where the object is used. Otherwise returns FALSE. warnings::fatal_enabled() Return TRUE if the warnings category with the same name as the current package has been set to FATAL in the calling module. Otherwise returns FALSE. warnings::fatal_enabled($category) Return TRUE if the warnings category $category has been set to FATAL in the calling module. Otherwise returns FALSE. warnings::fatal_enabled($object) Use the name of the class for the object reference, $object, as the warnings category. Return TRUE if that warnings category has been set to FATAL in the first scope where the object is used. Otherwise returns FALSE. warnings::warn($message) Print $message to STDERR. Use the warnings category with the same name as the current package. If that warnings category has been set to "FATAL" in the calling module then die. Otherwise return. warnings::warn($category, $message) Print $message to STDERR. If the warnings category, $category, has been set to "FATAL" in the calling module then die. Otherwise return. warnings::warn($object, $message) Print $message to STDERR. Use the name of the class for the object reference, $object, as the warnings category. If that warnings category has been set to "FATAL" in the scope where $object is first used then die. Otherwise return. warnings::warnif($message) Equivalent to: if (warnings::enabled()) { warnings::warn($message) } warnings::warnif($category, $message) Equivalent to: if (warnings::enabled($category)) { warnings::warn($category, $message) } warnings::warnif($object, $message) Equivalent to: if (warnings::enabled($object)) { warnings::warn($object, $message) } warnings::register_categories(@names) This registers warning categories for the given names and is primarily for use by the warnings::register pragma, for which see perllexwarn. See "Pragmatic Modules" in perlmodlib and perllexwarn. perl v5.16.2 2012-10-25 warnings(3pm)
All times are GMT -4. The time now is 12:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy