Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to use the "grep/egrep" command to search files. Post 302277858 by Rhije on Sunday 18th of January 2009 01:01:46 PM
Old 01-18-2009
Oh my goodness I did it Smilie

I was thinking at first I screwed up because I came up with no results, and was getting frustrated, then I realized the sample you provided did not have 10|11 Smilie

So here is the code with find and awk.. although you can alter that..

Code:
find . -maxdepth 1 -type f | xargs awk '( ( $3 ~ /(10|11|12):[0-9]+/ ) && ( $6 ~ /^ERROR$/ ) ) { print FILENAME" : "$0; }'

You can also just do it using egrep, which is a lot shorter, and uses a pretty good regex..

Code:
egrep -r "(10|11|12):[0-9]+ \([a-zA-Z]+\) [a-zA-Z] ERROR$" *
test.txt:641550 18.01 12:13 (emailrouter) R ERROR

Pretty cool I think. Is this what you were asking?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep/cat/more -- search in a txt file and display content from a specific "keyword"

Hi, I have a .txt file Sample: ===================== NEXT HOST ===================== AEADBAS001 ip access-list extended BLA_Incoming_Filter ip access-list extended BLA_Outgoing_Filter access-list 1 permit xxxxxxxxxxxxxx access-list 2 permit xxxxxxxxxxxxxx =====================... (4 Replies)
Discussion started by: I-1
4 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. UNIX for Dummies Questions & Answers

search ")" with egrep - egrep: syntax error

Hi Guys, we have a shell script which basically query the Database which retrieves huge data and use the data with "egrep" . Now there is some data which contains characters like "abc)" and the same is used like below : "egrep (.+\|GDPRAB16\|GDPR/11702 96 abc)\|$ temp.txt" now while... (7 Replies)
Discussion started by: sagarjani
7 Replies

4. Shell Programming and Scripting

ps -ef | grep "string1" "string2" " "string3"

Hi all, can any one suggest me the script to grep multiple strings from ps -ef pls correct the below script . its not working/ i want to print OK if all the below process are running in my solaris system. else i want to print NOT OK. bash-3.00$ ps -ef | grep blu lscpusr 48 42 ... (11 Replies)
Discussion started by: steve2216
11 Replies

5. Shell Programming and Scripting

grep - search after line containing "unavailable"

Hi everybody; I have a file status.txt: Following 163 ports are up: ----------------------------------------------------- MOD PORT PORTNAMES ABCDEFG1 ABCDEFG2 STA TYPE 1 Prt122 port323-1/2/3 11111 11111 1111 A 1 Prt126 port328-1/2/3 11111 11111 ... (7 Replies)
Discussion started by: gc_sw
7 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Problem with "find" and "grep" command

I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank). In a first approach I coded: find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt But this doesn't work. I got an error (under Ubuntu): grep:... (5 Replies)
Discussion started by: pstein
5 Replies

8. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

9. UNIX for Dummies Questions & Answers

Egrep confusion with "I" and "-I" pattern

I am executing following command egrep -w I filename.txt the filename.txt has following data .... -I 07-18 08:31:19.924 9880 6 SessionManager ConnectConfig: ConfigurationWebService LoginResults=SuccessfulLogin I am so hungry that I need to eat I expect egrep to print only the second... (1 Reply)
Discussion started by: VBG
1 Replies

10. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies
DATEFMT_GET_ERROR_CODE(3)						 1						 DATEFMT_GET_ERROR_CODE(3)

IntlDateFormatter::getErrorCode - Get the error code from last operation

	Object oriented style

SYNOPSIS
public int IntlDateFormatter::getErrorCode (void ) DESCRIPTION
Procedural style int datefmt_get_error_code (IntlDateFormatter $fmt) Get the error code from last operation. Returns error code from the last number formatting operation. PARAMETERS
o $fmt - The formatter resource. RETURN VALUES
The error code, one of UErrorCode values. Initial value is U_ZERO_ERROR. EXAMPLES
Example #1 datefmt_get_error_code(3) example <?php $fmt = datefmt_create( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); $str = datefmt_format($fmt); if (!$str) { printf( "ERROR: %s (%d) ", datefmt_get_error_message($fmt), datefmt_get_error_code($fmt) ); } ?> Example #2 OO example <?php $fmt = new IntlDateFormatter( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); $str = $fmt->format(); if (!$str) { printf( "ERROR: %s (%d) ", $fmt->getErrorMessage(), $fmt->getErrorCode() ); } ?> The above example will output: ERROR: U_ZERO_ERROR (0) SEE ALSO
datefmt_get_error_message(3), intl_get_error_code(3), intl_is_failure(3). PHP Documentation Group DATEFMT_GET_ERROR_CODE(3)
All times are GMT -4. The time now is 12:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy