Re: Copying the same file to multiple directories

From: Jean-Pierre Radley (jpr_at_jpr.com)
Date: 07/01/03


Date: 1 Jul 2003 13:44:28 -0400

Nachman Yaakov Ziskind typed (on Tue, Jul 01, 2003 at 04:34:13PM +0000):
| ... say I wanted to copy a file, call it "welcome", to every user's home
| directory. I know that all the folders live in /usr; thus /usr/first,
| /usr/second, ... /usr/thousand-and-twenty-two, ...
|
| IOW, I want to automate:
|
| $ cd /usr
| $ cp /path-to-welcome first
| $ cp /path-to-welcome second
| $ cp /path-to-welcome third
| $ cp /path-to-welcome fourth
|
| etc.
|
| What's the nicest/easiest way to do this? SCO 506.

        #!/bin/ksh
        for D in `awk -F: '$3 >= 200 { print $6 }' /etc/passwd`
        do
            [[ -f $D/.profile || -f $D/.login ]] && cp /path-to-welcome $D
        done

Slight aside: 5.0.7 does not place users in /usr by default, but in /u.
Take the trouble to move them all there now, it will make your eventual
upgrade far less annoying. The script I just wrote gives you the bare
bones for another script to both edit /etc/passwd and move the home
directories.

-- 
JP


Relevant Pages

  • automate dcpromo during nt4 pdc upgrade to W2k3 DC
    ... I am attempting to script the upgrade of a NT4 PDC to a W2K3 domain ... I have set the UnAttendMode to ... FullUnattended and the upgrade works perfectly up to the point where the ... @rem SetupMgrTag ...
    (microsoft.public.windows.server.migration)
  • Re: samba-common = 3.0.23d-4 but 3.0.24-2 is installed
    ... wants to upgrade to is 3.0.23d-4 which is lower. ... The problem is that the pre-removal script ... Reading package lists... ... warning - old pre-removal script returned error exit status 102 ...
    (Debian-User)
  • Re: Can someone help me write a "yes-man" program
    ... not work with the Ubuntu system upgrade script, ... which upgrade script you mean. ... from optparse import OptionParser ...
    (comp.lang.tcl)
  • Re: FC2 upgrade-X problem
    ... Immideately after upgrade completed I ran 'yum update' ... > getting the X server to launch. ... I made up a test script that runs all the ... > longer able to run startx. ...
    (Fedora)
  • Re: Some thoughts about Fedora Core 1 packages upgrade
    ... > upgrade hundreds of clients through Internet(big burden on Internet ... > building options, we have to download source RPMs as well, so there ... i'd recommend the apt-mirror script to be run once a day, ...
    (Fedora)