Search a phrase than start with 'a' and ends at 'b, middle anything

View: New views
2 Messages — Rating Filter:   Alert me  

Search a phrase than start with 'a' and ends at 'b, middle anything

by Eduardo-54 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I trying to search a phrase than start with 'a' and ends at 'b, middle
anything,
but if i use the command as '$ grep '^a * b$' like in the man, don't works,

Because?

I hope an answer,

Nice to write you,
Eduardo Ortega (Student in progress of LPI).

Re: Search a phrase than start with 'a' and ends at 'b, middle anything

by Bob Proulx :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Eduardo wrote:
> I trying to search a phrase than start with 'a' and ends at 'b, middle
> anything,
> but if i use the command as '$ grep '^a * b$' like in the man, don't works,

Your pattern includes " * " which would look for zero or more spaces
followed by a single space.  This could also be described as one or
more spaces.  But you say you want it to match anything and not just
spaces.  So you would want to use ".*" instead.  The '.' matches any
character and the '*' says zero or more of the previous any character.

Try this:

  grep '^a.*b$'

Bob