1

So I'm creating a simple grep command that gets only the last logged in people who's username starts with 161 and has 3 digits next to it:

last | grep "^161[0-9]{3}"

However it doesn't print anything even though it has these usernames on the list. Whats even more weirder is if I do egrep instead of grep

last | egrep "^161[0-9]{3}"

The command works.

Can anyone explain what is the difference?

1 Answers1

2

As steeldriver already pointed out, grep uses basic regular expressions whereas grep -E and egrep use extended regular expressions.

last | grep  '^161[0-9]\{3\}'
last | egrep '^161[0-9]{3}'
Hauke Laging
  • 90,279