Hire me if you like: blake.irvin@gmail.com

Tuesday, March 06, 2007

A simple 'cp' loop to copy to mutiple directories

#!/bin/bash

for object in `ls`
do cp /path/file1 $object/subdir; done


This works when running the script from the parent directory of the
dirs you want to copy to. That is, it will copy the named file to the
dirs/dir trees listed when you do an 'ls' command in the script's
working directory.

No comments:

Archive