Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List UID

Status
Not open for further replies.

job357

Technical User
Sep 16, 2002
106
US
I am using the following to list a range of UIDs in /etc/passwd in the range of 5000.

getent /etc/passwd |cut -d: -f: |awk '/5***/'

The problems is that '*' list additional numbers, all I want is anything in the range of 5000.

eg
5001-5400

not
5001-54444



Thanks.
 
very dirty:

awk '{IFS=":"}
if ($3 >4999 && 5999 >$3) print;
' /etc/passwd


don't forget, RTFMP :) guggach
 
nawk -F ':' '$3 > 4999 && $3 < 5999' /etc/passwd

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Maybe something like this:

awk -F: '{ print $1,$3 }' /etc/passwd | grep -e 5[0-9][0-9][0-9]

jsmith1 5000
.
.
.
rjohnson 5999

remove the "$1," if you don't want the usernames.
 
vlad: you one-line is better
spamly: see man awk

don't forget, RTFMP :) guggach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top