Created
September 7, 2011 18:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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