I want to use the 'find' command and have it follow symbolic links. However, I need to call the command from other code (IDL, which doesn't have very nice built-in file searching) on both a RedHat and a Mac OS X system.

The problem is, the RedHat system uses GNU find version 4.1.20, while the mac find is some BSD version. In mac find, you use find -L to follow symlinks. In the GNU version, you use find -follow. There don't appear to be any common options between the two for following symbolic links.

A workaround for my machines is to change the find to a private version of my own, but that is not an acceptable option for distributing the code. Can anyone recommend alternatives? Is there something in the find manual I missed telling how to follow symbolic links that does not depend on the version?

link|improve this question

1  
You should past that as an answer and not as an edit. – surfasb Jan 1 at 9:29
feedback

1 Answer

up vote 1 down vote accepted

I was just using find incorrectly.

This fails:

$ find -follow . -name "t*"
find: ollow: No such file or directory

While this works:

$ find . -name "t*" -follow

I think it's because -f is a special option to find.

Note that the GNU version of find also does not allow -follow before the path, but it at least gives a useful error:

find: paths must precede expression
link|improve this answer
2  
This is what the second line of man find has to say about this: find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]. The path always comes before the search expression... – Daniel Beck Jan 6 at 19:07
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.