At 04:30 PM 1/5/00 -0500, you wrote:
>I would like to bulk copy a file to the same location in every users
>directory. What would be the command for this?
There are probably easier ways to do this, but off the top of my head I'd
do it like this:
Assuming you are using the standard arrangement for user home directories
(i.e. a user named "XX" has a home directory named "/home/XX") we want to
loop through each home directory, create the directory to store the file in
(if necessary) and then copy the file in.
--- CUT HERE ---
# Put the file /root/sourcefile into "public_html/destfile" in each user's
home # dir
for f in /home/*; do
# For each home directory
if [ -d $f ] ; then
# Check if the location directory exists
if [ ! -d $f/public_html ]; then
#If it doesn't exist, create it
mkdir $f/public_html
fi
# Copy the source file into the location
cp /root/sourcefile $f/public_html/destfile
fi
done
--- CUT HERE ---
If you have non-home dirs in /home or if your user's home dirs are
distributed around, you may want to either just feed a whitespace seperated
list of user home dirs into the for loop or use a filter like:
cut -f 6 -d : /etc/passwd
To retrieve the complete list of users' home directories from the passwd
file. Even then you might want to preface this with a grep filter to remove
"special" users like root ftp and daemon and the like.
--
Q: What's tiny and yellow and very, very, dangerous?
A: A canary with the super-user password.
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.