[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Regex Question



On Fri, Jul 13, 2007 at 03:49:23PM -0600, Telly Williams wrote:
> Hi,
> 
> 	I'm reading up on Regular Expressions and I have a question about alternation.
> 
> 	I have the sentences: "There was a dog in the house." & "A house on the hill."
> 
> 	Both of these are in a file (named "regex") on two different lines.
> 
> 	My understanding of alternation is that it will look both for what is on the right and left of the pipe.
> 
> 	So, if I type: 
> 
> 		grep in|hill regex
> 
> 	isn't that supposed to give me both sentences in stdout?
> 
> 	When I type that, I get nothing at all on return.  I've even typed it as:
> 
> 		grep in\|hill regex
> 
> 	and I still get nothing.  What am I doing wrong?  Is what I'm typing and what I'm asking for two different things?  Thanks.

I think this is because you are using an extended (enhanced - one of those e 
words).

try egrep or grep -e  


also might want to try 

grep -e "(in|hill)" file

> 
> TW
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
> 

Attachment: signature.asc
Description: Digital signature


Reply to: