Title: Re: [vchkpw] [semi-OT] which is more portable?

On Thu, 2004-07-15 at 13:31 -0500, Jeremy Kitchen wrote:
> grep vpopmail /etc/passwd | awk -F ":" '{print $6}'
> or
> grep vpopmail /etc/passwd | cut -d':' -f6
I'd go with awk, personally. Poking around my network a bit I'm finding
cut on solaris and sco clients (and I know its on the *BSDs), however
awk is a truly old school tool, and is almost gauranteed to be on all
UNIX variants.
> I appreciate any input (including if /etc/passwd is not portable, it's
> been on 
> every system I've ever seen, but I'm relatively new to *nix compared
> to a lot 
> of you I'm sure) I can get :)
/etc/passwd should be pretty portable however the field order I don't
think is specified in any POSIX or equivalent spec. Depending on what
info you're looking for you may want to see if something like perl's
builtin getpw function would work (perldoc -f getpw) since they've
ported perl to virtually every *nix on earth and have dealt with all of
these shifting "standard" things.
> Thanks.
> -Jeremy
> -- 
Hope that helps,
Nicholas Harring
System Administrator
Webley Systems

Reply via email to