Skip to content

Instantly share code, notes, and snippets.

@kisom
Created September 7, 2011 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kisom/1201280 to your computer and use it in GitHub Desktop.
Save kisom/1201280 to your computer and use it in GitHub Desktop.
a simple POSIX shell script to read a MANIFEST and copy it to another dir
#!/bin/sh
# simple shell script to read a manifest file and copy the files in the
# manifest to another dir, i.e. to build a distribution
if [ "$1" -a "$2" ]; then
MANIFEST=$1
DESTDIR=$2
else
echo "usage: distcp.sh MANIFEST DESTDIR"
echo " MANIFEST should be a file containing files to DESTDIR"
echo ""
exit 1
fi
FILELIST=$(cat $MANIFEST | xargs)
if [ -z "${FILELIST}" ]; then
echo "MANIFEST cannot be empty!"
exit 1
fi
for file in ${FILELIST}
do
if [ ! -d ${DESTDIR}/$(dirname ${file}) ]; then
echo "creating ${DESTDIR}/$(dirname ${file})"
mkdir -p ${DESTDIR}/$(dirname ${file})
fi
cp -ruv -t ${DESTDIR}/$(dirname ${file})/ $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment