Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Apr 2002 22:09:22 +0200
From:      "Patrick O'Reilly" <bsd@perimeter.co.za>
To:        parv <parv@pair.com>
Cc:        f-q <freebsd-questions@freebsd.org>
Subject:   Re: Redistributing adduser's dotfiles to users
Message-ID:  <200204062205.07871@.perimeter.co.za>
In-Reply-To: <20020406080531.GB90139@moo.holy.cow>
References:  <1018013904.3cada8d0cf171@mail.broadpark.no> <014f01c1dcab$78a608b0$b50d030a@PATRICK> <20020406080531.GB90139@moo.holy.cow>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat 06 Apr 02 10:05, parv wrote:
> just some minor notes, nothing much (consider '>' to be secondary
> shell prompt)...
>
> % # cat /etc/passwd | cut -d":" -f1 > /tmp/usr-list
>
> cut -d":" -f1 < /etc/passwd | grep -v '^#' > /tmp/usr-list
>
> #  ...or...
>
> awk -F':' '! /^#/ { print $1}' < /etc/passwd > /tmp/usr-list
>
> % # vi /tmp/usr-list    (remove any accounts that you don't want to
> % affect, like root?)

True!  I was relying on the user to scrub the rubbish during the "vi" :)

> % # cd /home
> % # for usr in `ls`
>
> # no need for backquotes, or ls; use shell globbing
>
> for usr in *
>

Actually, I subsequently corrected myself - using `ls` after so 
carefully preparing /tmp/usr-list was a logic error in my code.  I see 
you fell for it too :)

The intended solution was:
for usr in `cat /tmp/usr-list`

>
> % > do
> % > echo ${usr}
> % > for file in `ls /usr/share/skel`
>
> > for file in /usr/share/skel/*
>
> % > do
> % > newfile=`echo ${file} | cut -d"." -f2`
> % > cp /usr/share/skel/${file} ${usr}/.${newfile}
>
> # temporary variable "newfile", echo & cut in sub shell can be done
> # away with shell parameter expansion
>
> > do
> > cp $file ${usr}/.${file#*.}
>

This is beyond me - time to go play with it !

> % > done
> % > chown -R `grep "^${usr}" /etc/passwd | cut -d":" -f3,4` ${usr}
>
> well, no change there.  my method would have been bit more
> complicated.  i can't avoid "cut" after all.
>
>
> % > done
>
>
> ...just another way to do somethings.
>

And so we learn! :)   Thanks.

Patrick.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204062205.07871>