What does this
egrep command do?
egrep '[^A-M][0-9]+' /etc/passwd
So far I think it searches for any file in
/etc/passwd that starts with A-M and includes the number(s) 0-9. Is that right?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
^ at the beginning of an expression means "beginning of line". However,
^ inside a bracket expression matches everything not in that expression. So, for example, while
[abcd] matches the letters a, b, c, or d, the expression
[^abcd] matches everything other than those letters.
So the expression you've got matches "anything not A-M, followed by 1 or more digits".
The following lines would all match that expression:
mmmmmz09123 00 this is a very long line that includes the number 1.
Because they all contain a digit preceded by something that is not in the range A-M.