36 lines
552 B
Bash
Executable File
36 lines
552 B
Bash
Executable File
#! /bin/sh
|
|
|
|
if [ "$1" = "-d" ]
|
|
then
|
|
destdir=$2
|
|
printfilesCmd=$3
|
|
debug_state="-d"
|
|
else
|
|
destdir=$1
|
|
printfilesCmd=$2
|
|
debug_state=""
|
|
fi
|
|
|
|
if [ "${destdir}" = "" -o "${printfilesCmd}" = "" ]
|
|
then
|
|
echo "Usage: copyfiles [-d] destdir printfilesCmd"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -d ${destdir} ]
|
|
then
|
|
echo "Error: destdir must be a directory"
|
|
exit 1
|
|
fi
|
|
|
|
for file in `$printfilesCmd $debug_state`
|
|
do
|
|
if cp -R ${file} ${destdir}
|
|
then
|
|
echo "copying ${file} to ${destdir}"
|
|
else
|
|
echo "ERROR: could not find ${file}"
|
|
exit 1
|
|
fi
|
|
done
|