Note: You are viewing an old version of this page. View the current version.

Differences between version 2 and previous revision of KnowledgeBase/Scripts/clone.sh.

Other diffs: Previous Major Revision, Previous Author

Newer page: version 2 Last edited on Sunday, 19 April 2009 11:32:02 by CyberLeo Revert
Older page: version 1 Last edited on Monday, 17 September 2007 19:34:00 by CyberLeo Revert
@@ -1,5 +1,6 @@
-<verbatim
+<?plugin RawHtml  
+<pre class="brush: bash;"
 #!/bin/sh 
  
 src="${1}" 
 dst="${2}" 
@@ -31,5 +32,6 @@
 echo "Hardlinking files..." 
 ( cd "${src}" && find . -type f -print ) | while read file; do ln "${src}/${file}" "${dst}/${file}"; done 
  
 echo "All done!" 
-</verbatim
+</pre>  
+?

version 2

Plugin RawHtml disabled. Raw HTML is only allowed in locked pages.
<?plugin RawHtml
<pre class="brush: bash;">
#!/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!"
</pre>
?>