1833758 Members
2543 Online
110063 Solutions
New Discussion

need help

 
sanjit
Occasional Advisor

need help

Please tell me how to write a shell script to find all users on my system whose user id are greater than 99.

Thanks for all your help,
Sanjit
3 REPLIES 3
Rick Garland
Honored Contributor

Re: need help

This will work for you:

cat /etc/passwd | awk -F: '{if (($3 > 98)) print $1}'

Rick Garland
Honored Contributor

Re: need help

Whoops, change the 98 to a 99.

Checking the UID field for UIDs that are greater than 99. If true, then print the $LOGNAME of the corresponding UIDs. The print $1 at the end can be modified to print $0 if you want to see the entire line for the output that matches the awk condition.
federico_3
Honored Contributor

Re: need help

try this:

cat /etc/passwd| awk 'BEGIN {FS = ":"} {if $3 > 99 ) print "username="$1 " " "UID=" $3}'

Federico