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


Closed Thread    
Thread Tools Search this Thread Display Modes
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

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 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 08:45 PM.. Reason: CODE tags
Sponsored Links
Old 07-18-2013
Don Cragun's Avatar
Don Cragun Don Cragun is offline Forum Staff  
Join Date: Jul 2012
Last Activity: 2 March 2015, 5:37 AM EST
Location: San Jose, CA, USA
Posts: 5,754
Thanks: 234
Thanked 1,909 Times in 1,627 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 12:55 PM
awk command to replace ";" with "|" and ""|" at diferent places in line of file shis100 Shell Programming and Scripting 7 03-16-2011 09:59 AM
cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' harshakusam Shell Programming and Scripting 4 08-25-2009 12:21 PM
Explain the line "mn_code=`env|grep ""|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM

All times are GMT -4. The time now is 07:10 AM.