Issue
I have a file and it contains lines
users:x:22845:test1
test-users:x:22845:test2,test3
If I run grep users: file
, it shows both lines becuase both have users:
.
How can I get only users:x:22845:
Thank you
Solution
Perhaps specify that the line must start with "users". You can use the caret (^) special character to anchor the match at the beginning of the line:
egrep '^users:' file
This will not match the line beginning with "test-users".
Answered By - jspcal