Reputation: 3232
For example how would I get lines that begin with foo and end with bar?
Example lines:
foo12345abar
fooabcdbar
fooy7ghqqbar
This does not seem to work
grep '^foo[.]*bar$'
What is the correct regex?
Upvotes: 1
Views: 48
Reputation: 726479
The reason your expression does not work is because [.]
represents a dot, literally. Your expression would match strings that look like this:
foo.......bar
foo...bar
boobar
To make it work remove square brackets []
around the dot meta-character:
^foo.*bar$
Upvotes: 2