[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] skel
And Lo! The Great Prophet " Mr. Adam ALLEN" uttered these words of wisdom:
>
> cat /etc/shadow | grep "^$user" | awk -F: {'print $1":"$2'}
> > $homedir/.htpasswd
>
Caution ... in the interests of sanity, change the grep pattern to use:
grep "^$user:"
ie, a trailing colon, as otherwise when grep tries to do match the
username bob, it will pull back bob, bobby, bobs, bobbob, etc ... :)
Alternatively, drop the grep and do it all with awk:
awk -F: -vU=$user '$1==U { print $1":"$2 }'
or:
awk -F: -vU=$user -vOFS=: '$1==U { print $1,$2 }'
Chris...
--
\ Chris Johnson \
\ cej [at] nightwolf.org.uk \
\ http://cej.nightwolf.org.uk/ ~-----------------------------------+
\ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____
___________________________________________________________________
Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html
GNU the choice of a complete generation.