I try to search for lines that start with "1" using
ls -1 | grep ^1*
but it returns lines that do not start with 1. What I am missing here?
grepregular expression
I try to search for lines that start with "1" using
ls -1 | grep ^1*
but it returns lines that do not start with 1. What I am missing here?
Best Answer
Your regular expression doesn't mean what you think it does. It matches all lines starting (^) with one (1) repeated zero or more (*) times. All strings match that regular expression.
grep '^1'
does what you want.