Created
March 4, 2014 00:44
-
-
Save raamdev/9337948 to your computer and use it in GitHub Desktop.
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/bash | |
SAVEIFS=$IFS | |
while read -u 3 line | |
do | |
case "$line" in \#*) continue ;; esac | |
target=`IFS=$(echo -en "\n\b") ; echo $line | cut -d'>' -f1 | sed 's/ *$//g' | sed 's/^ *//g'` | |
src=`IFS=$(echo -en "\n\b") ; echo $line | cut -d'>' -f2 | sed 's/ *$//g' | sed 's/^ *//g'` | |
if [ -L "$target" ]; then | |
echo "Skipping $target (already a symbolic link)" | |
continue | |
fi | |
if [ ! -d "$src" ] && [ ! -f "$src" ]; then | |
echo "Error: Could not find source $src" | |
continue | |
fi | |
if [ -d "$target" ] || [ -f "$target" ]; then | |
echo "$target exists!" | |
read -p "Move it to $target.backup and use $src instead? " -n 1 -r | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
echo "" | |
mv "$target" "$target.backup" | |
else | |
continue | |
fi | |
fi | |
echo "Creating $target -> $src" | |
ln -s "$src" "$target" | |
done 3< $1 | |
IFS=$SAVEIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment