grep lines starting with "1" in Ubuntu
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.
Did you try the following?
ls -1 | grep "^1"
That is, remove the *
, which basically tells grep
, find zero or more occurances of the ^1
expression. In other words: match the lines that start with a 1, or not.
Although this doesn't answer your question, this is a better solution to what appears to be your goal:
ls -ld 1*
You can use a shell glob to list all files that start with 1
. Note that *
has a different meaning in shell globbing than regular expressions.