Created
August 5, 2012 16:07
-
-
Save fuzzy/3265555 to your computer and use it in GitHub Desktop.
lndir in Sh
This file contains hidden or 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
slndir() { | |
if [ -z "${1}" ] || [ -z "${2}" ]; then | |
echo 'Usage: slndir /dir1 /dir2/' | |
else | |
SRC=${1} | |
if [ "${2}" = "." ] || [ "${2}" = "./" ]; then | |
DST=${PWD} | |
else | |
DST=${2} | |
fi | |
tmp=$(mktemp /tmp/cpkg.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX) | |
echo ${PWD} > ${tmp} | |
cd ${SRC} | |
for itm in $(ls); do | |
if [ -x ${DST}/${itm} ] && [ -d ${DST}/${itm} ]; then | |
`slndir ${SRC}/${itm} ${DST}/${itm}` | |
else | |
ln -s ${d}/${itm} ${DST}/${itm} | |
fi | |
done | |
cd $(cat ${tmp}) | |
rm -f ${tmp} | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment