• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

How to grep only ID's

In the  /etc/passwd directory file. there are several users, I just want to locate the primary user  ID's account that starts with 1000 and 1003.

I did the following grep -e "1000" -e "1003" /etc/passwd  but the output also prints 1020 1028 etc.

I just want the 1000 and the 1003 any suggestions.
0
9334gonzalez
Asked:
9334gonzalez
  • 3
  • 2
3 Solutions
 
TintinCommented:
awk -F: '$3==1000 || $3==1003 {print}' /etc/passwd
0
 
expert_tanmayCommented:
grep -e '^100[03]' /etc/passwd
0
 
expert_tanmayCommented:
sorry it will be
grep '^100[03]' /etc/passwd

-e is not needed
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
9334gonzalezAuthor Commented:
grep -e '^100[03]' /etc/passwd


I tried this one and I didn't get any did I missed something
0
 
expert_tanmayCommented:
try without -e
0
 
9334gonzalezAuthor Commented:
Thank you,
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now