Egrep confusion with "I" and "-I" pattern | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

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

UNIX for Dummies Questions & Answers


Tags
egrep

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-18-2013
VBG VBG is offline
Registered User
 
Join Date: Jul 2013
Last Activity: 19 July 2013, 7:08 AM EDT
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Linux Egrep confusion with "I" and "-I" pattern

I am executing following command

Code:
egrep -w I filename.txt

the filename.txt has following data ....


Code:
-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 line, however it prints both the lines.
Please assist.
Moderator's Comments:
Please use CODE tags when displaying sample code, input, and output.

Last edited by Don Cragun; 07-18-2013 at 07:45 PM.. Reason: CODE tags
Sponsored Links
    #2  
Old 07-18-2013
Don Cragun's Avatar
Don Cragun Don Cragun is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 30 September 2014, 5:46 AM EDT
Location: San Jose, CA, USA
Posts: 4,757
Thanks: 181
Thanked 1,586 Times in 1,350 Posts
The -w option to grep is not specified by the standards. Some implementations of grep, egrep, and fgrep do not accept a -w option and those that do may have different ideas of what it means. A common interpretation of -w is that the given regular expression is matched if it matches a "word" where a word consists of alphanumeric and underscore characters. Since the minus sign is not in this set, the I in -I 07-18 is a match for the word I . To get the exact meaning on your OS, look at the description of the -w option on the grep(1) man page on your system.
The Following User Says Thank You to Don Cragun For This Useful Post:
VBG (07-19-2013)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to use "cut" or "awk" or "sed" to remove a string timmywong Shell Programming and Scripting 8 02-12-2012 11:55 AM
awk command to replace ";" with "|" and ""|" at diferent places in line of file shis100 Shell Programming and Scripting 7 03-16-2011 08:59 AM
cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' harshakusam Shell Programming and Scripting 4 08-25-2009 11:21 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 12:52 AM



All times are GMT -4. The time now is 05:47 AM.