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:
- If the prompt is y (yes) Then: Find all the symbolic links in
~ (the home directory) and execute a for loop that will delete them and show which one has been deleted.
Although now it does not perform part removal, everything works fine. I did not include the part that works, this is just a bunch of ln -s .
I'm on Mac OS X Mountain Lion (10.8.2), using Zsh as a shell, this is in the .sh file.
The problem I am facing is that nothing is happening and therefore it just says:
ln: /Users/eduan/.vim/vim: File exists ln: /Users/eduan/.vimrc: File exists ln: /Users/eduan/.gvimrc: File exists Done...
and etc.
Thanks so much for any help you can provide!
EDIT:
Now I 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
source share