shell scripts and /etc/passwd

stanonik at nprdc.navy.mil stanonik at nprdc.navy.mil
Fri Nov 3 05:01:00 AEST 1989


In porting shell scripts from 4.3bsd to sunos4.0.X we realized that we
couldn't just grep/sed/awk through /etc/passwd any longer because of
entries such as

	+ at guests

Rather than make each script know how to expand this stuff, I looked
around for some existing utility that simply expands the /etc/passwd file.
Well, I couldn't find it.  I was expecting some option to finger or who or
...  I ended up writing a little program that

	while(pwd = getpwent())
		printf("%s:%s:%d:%d:%s:%s:%s\n",
			pwd->pw_name,
			pwd->pw_passwd,
			pwd->pw_uid,
			pwd->pw_gid,
			pwd->pw_gecos,
			pwd->pw_dir,
			pwd->pw_shell);

Have missed some existing tool?  True, this seems trivial enough to write,
but using an existing tool avoids grief later (such as forgetting to
include this tool when doing the next install).

Thanks,
Ron Stanonik
stanonik at nprdc.navy.mil



More information about the Comp.sys.sun mailing list