środa, 20 października 2010

find and symlinks

A pearl of wisdom from today problems: find does not automatically descend into symlinks to directories. You have to ask it to, by using -follow. It turns out that trivia is not widely known at this site.
This has today surfaced with filesystem hierarchy resembling below:

drwxr-xr-x /usr/local/bin/Testing
lrwxrwxrwx /opt/Testing -> /usr/local/bin/Testing

It translates into: /usr/locla/bin/Testing is a directory and /opt/Testing is a symbolic link to this directory. Within this directory lies a file test.t.
A developer was bewildered why, when he cds into /opt/Testing, following find the file:

find . -name test.t

and following does not:

find /opt/ -name test.t

Reason is simple. find, by default, will not follow symlinks to directories. There is an option for that: -follow.

Brak komentarzy: