Bash: find all symbolic links recursively

Рубрика: IT. Сети. Связь -> Articles in English
Метки: | |
Понедельник, 25 ноября 2013 г.
Просмотров: 5494
Подписаться на комментарии по RSS

It would seem there is no problem to find all symbolic links within the directory recursively like find . -type l . This is exactly how I hoped to make it, but got not the result I expected.

Actually, this way we don't get those symbolic links that are located within the directories which, in its turn, are pointed by the symbolic links that are found in the directory of initial search. It is complicated enough, but I think you see the issue :)

So this is how to solve it:

1. You can use ls recursively and so that this command will follow all the symbolic links found and search new links there.

ls -lR . | grep ^l

2. Another way is to take advantage of find command, but note, firstly, there must be -l option which will allow us to follow symbolic links already found, and secondly, pay attention that I use -xtype instead of -type. This is due to the fact that:

l    symbolic link; this is never true if the -L option or the
     -follow option is in effect, unless the symbolic link  is
     broken.  If you want to search for symbolic links when -L
     is in effect, use -xtype.

(from man find )

Thus, the second solution:

find -L . -xtype l
twitter.com facebook.com vkontakte.ru mail.ru friendfeed.com pikabu.ru blogger.com liveinternet.ru livejournal.ru memori.ru google.com bobrdobr.ru yandex.ru del.icio.us

Оставьте комментарий!

Не регистрировать/аноним

Используйте нормальные имена.

Если вы уже зарегистрированы как комментатор или хотите зарегистрироваться, укажите пароль и свой действующий email.
(При регистрации на указанный адрес придет письмо с кодом активации и ссылкой на ваш персональный аккаунт, где вы сможете изменить свои данные, включая адрес сайта, ник, описание, контакты и т.д.)



(обязательно)