Coder's Guild Mailing List

Re: number list condenser...?

Posted by Peter Palfrader on 2000-05-23

Hi Darryl!

Darryl Hall schrieb am Dienstag, dem 23. Mai 2000:

> I've recently moved from NT admin into Unix admin

good idea :)

> and I've been given the task of coding a routine to go through the UID's in
> the 'passwd' file and shuffle them to remove the big gaps we have in the
> list as we are close to the upper limit of valid ID's Eg.

Are you really sure you want this? You'ld have to change file
ownerships and perhaps two or three other things too I'ld think.

Anyway, something like this might be a good start:


weasel@marvin:~$ cat /etc/passwd | perl -ne '$i++; @data = split /:/; @data[2]=$i; print (join ":", @data)';

(note: awk should be able to handle this too (maybe even
better). Unfortunatly I know awk not good enough :(
*filebugreportagainstweasel* )



You should check whether /etc/passwd is the correct file to
modify. Some Unices have a different file to store user data and
/etc/passwd is only created for backwards compatibility (OpenBSD for
examle has /etc/{spwd,pwd}.db).

If you use shadow passwds make sure to update them too.



I'ld think leaving userids how they are currently was a better
idea. You can create new users in the wholes. 

					yours,
					peter

-- 
PGP encrypted messages prefered.
http://www.cosy.sbg.ac.at/~ppalfrad/