How do Iist dead symbolic link?
Hi All,
Please let me know as how to do listing of all the dead symbolic links for all the files and subfolders under a folder? Background Information: I tarred a folder(that has files and subfolders in it, along with files which are symbolic links to other files and are reffering by absolute path). I take the tar file and extract it onto a different machine under a different folder. Now the symbolic link files which are referring to other files by absolute path becomes invalid. Question: Now how do I run through all the files and folders under a folder and list ONLY those symbolic links that are "DEAD" or "INVALID", along with their name and the location of the file. Thanks in advance! Cheers Sunil Kumar |
There is a utility called symlinks that can find and remove dangling (dead ) symbolic links.
|
I have a script I use that will traverse directories looking for dead links, but I don't have it memorized. If you just want to look for dead links in a particular directory (/usr/bin for example) you can
Code:
for link in /usr/bin/*; do [ -h "$link" -a ! -e "$link" ] && echo "Link $link is broken."; done |
Question 1:
On running, for $link in /usr/bin/*; do [ -h "$link" -a ! -e "$link" ] && echo "Link $link is broken."; done I am getting error message saying, "`$link': not a valid identifier" Question 2: Where do I get symlinks utility for Solaris? |
Oops!! Sorry, I got carried away with the $ symbol (The markets have been good this year :) ) See the revised command in my original post.
|
Wow, it works thanks. I did small change in the script.
for link in `find /usr/bin -name "*.*" `; do [ -h "$link" -a ! -e "$link" ] && echo "Link $link is broken."; done Unix Rocks! |
All times are GMT -5. The time now is 07:50 PM. |