Differences between version 3 and predecessor to the previous major change of KnowledgeBase/Scripts/clone.sh.
Other diffs: Previous Revision, Previous Author
| Newer page: | version 3 | Last edited on Sunday, 19 April 2009 13:34:53 | by CyberLeo | Revert |
| Older page: | version 1 | Last edited on Monday, 17 September 2007 19:34:00 | by CyberLeo | Revert |
@@ -1,5 +1,5 @@
-<verbatim
>
+<code bash
>
#!/bin/sh
src="${1}"
dst="${2}"
@@ -31,5 +31,5 @@
echo "Hardlinking files..."
( cd "${src}" && find . -type f -print ) | while read file; do ln "${src}/${file}" "${dst}/${file}"; done
echo "All done!"
-</verbatim
>
+</code
>
version 3
#!/bin/sh
src="${1}"
dst="${2}"
if [ -z "${src}" -o -z "${dst}" ]
then
echo "Usage: $(basename "${0}") <source> <dest>"
echo "Clones the source directory tree into destination, hardlinking all files."
echo "Useful for kernel build trees, when you wanna keep everything separate."
exit 64
fi
if [ ! -d "${src}" ]
then
echo "${src} doesn't appear to be a directory."
exit 32
fi
if [ -e "${dst}" ]
then
echo "${dst} already exists. Not overwriting."
exit 16
fi
echo "Creating directory structure..."
mkdir -p "${dst}"
( cd "${src}" && find . -type d -print0 ) | ( cd "${dst}" && xargs -0 mkdir -p )
echo "Hardlinking files..."
( cd "${src}" && find . -type f -print ) | while read file; do ln "${src}/${file}" "${dst}/${file}"; done
echo "All done!"
