How can I use 'grep' to get lines start with '* ' in my file?

I tried grep "*" myfile and grep "* " myfile but returns all the lines of my file.

link|improve this question

62% accept rate
feedback

2 Answers

The "*" is a special character that means "0 or more of the previous character." You need to escape this character.

grep '^\*' myfile
link|improve this answer
feedback
grep '^* ' myfile
link|improve this answer
This is incorrect, this would say that the line starts with 0 or more '' which is nothing. – Daisetsu May 13 '10 at 20:08
Perhaps then you can explain why it works here. – Ignacio Vazquez-Abrams May 14 '10 at 2:00
I think that what @Daisetsu is saying will only happen if grep has the -e switch. – Nathan Fellman May 26 '10 at 13:48
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.