I have the following:
read -p 'Delete old symlinks? y/n: ' prompt
if [ $prompt == [yY] ]
then
current_dir=$(pwd)
script_dir=$(dirname $0)
if [ $script_dir = '.' ]
then
script_dir="$current_dir"
fi
for sym in {find $PATH -type l -xtype d -lname "~"}
do
rm $sym
echo "Removed: $sym"
done
fi
What I'm trying to achieve is the following:
~
(home directory) and do a for loop on them which would delete them and output which one it deleted.Although right now it doesn't do the deleting part, the rest works fine. I didn't include the part that works, it's just a bunch of ln -s
.
I am in Mac OS X Mountain Lion (10.8.2), using Zsh as shell, this goes in a .sh
file.
The problem I am having is that nothing happens, and so it just says:
ln: /Users/eduan/.vim/vim: File exists
ln: /Users/eduan/.vimrc: File exists
ln: /Users/eduan/.gvimrc: File exists
Done...
etc.
Many thanks for any help you can provide!
EDIT:
I now have the following:
read -p 'Delete old symlinks? y/n: ' prompt
if [ $prompt == [yY] ]
then
find ~ -type l | while read line
do
rm -v "$line"
done
fi
find /path -type l | xargs rm
The first part lists the symlinks. Xargs
says for each of the returned values issue an rm
How about this?
find ~ -type l | while read line
do
rm -v "$line"
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With