Fixing broken links
Ralf Mardorf
silver.bullet at zoho.com
Wed Feb 17 03:02:01 UTC 2016
On Tue, 16 Feb 2016 14:16:35 -0800, rikona wrote:
>Before I move/delete/rename a file/dir, is there a way to tell if that
>will break links to that object?
Without doing it recursively, it's already tricky, since ...
[rocketmouse at archlinux Desktop]$ ls -Gg *
-rw-r--r-- 1 0 Feb 17 02:31 1
lrwxrwxrwx 1 6 Feb 17 03:34 not_tricky -> tricky
-rw-r--r-- 1 0 Feb 17 03:33 tricky
-rw-r--r-- 1 0 Feb 17 03:36 tricky_2
lrwxrwxrwx 1 10 Feb 17 03:49 very_tricky -> ./tricky_2
[rocketmouse at archlinux Desktop]$ item_name=tricky_2
[rocketmouse at archlinux Desktop]$ for l in $(find . -type l);do [[ "$(readlink $l)" = "$item_name" ]] && echo -e "\n### ### ### NOT OK ### ### ###\n";done
[rocketmouse at archlinux Desktop]$ item_name=tricky
[rocketmouse at archlinux Desktop]$ for l in $(find . -type l);do [[ "$(readlink $l)" = "$item_name" ]] && echo -e "\n### ### ### NOT OK ### ### ###\n";done
### ### ### NOT OK ### ### ###
[rocketmouse at archlinux Desktop]$ item_name=1
[rocketmouse at archlinux Desktop]$ for l in $(find . -type l);do [[ "$(readlink $l)" = "$item_name" ]] && echo -e "\n### ### ### NOT OK ### ### ###\n";done
... a link could be provided by different paths, so a script needs to
"translate" it always to the full path.
False positives could be caused by links that link against paths that
are only mounted on demand.
More information about the ubuntu-users
mailing list