help with simple regex expression

I am trying to grep the following line in a file using a bash shell:

(..)
admin1::14959::::::
(..)

It works with the following expression (as expected)

# cat file | grep ^[a-z0-9]*::
admin1::14959::::::

but it does not work with (not expected)

# cat /etc/shadow | grep ^[a-z0-9]+::

I assume the difference is the + vs. the *. According my
understanding the * matches the preceding character 0 or
more times and the + matches the preceding character 1
or more times. Therefore, the match should be in both cases
"admin1::"

I can not see my mistake. Any ideas ?

That's an extended regexp. Use grep -E .

1 Like

Or # cat /etc/shadow | egrep ^[a-z0-9]+::

Or # cat /etc/shadow | grep ^[a-z0-9][a-z0-9]*::

1 Like