Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I run this command find $HOME/MySymlinkedPath -name "run*.sh" nothing happens, and gives no error ('MySymlinkedPath' is a symlinked path to another hard drive other then my $HOME one).

These also fails:

find ~/MySymlinkedPath -name "run*.sh"
find /home/MyUserName/MySymlinkedPath -name "run*.sh"

And just to make it sure, this non existant path fails (of course) find $HOME/MySymlinkedPathDUMMYTEST -name "run*.sh" so the path is being found (because that error does not happen) but find doesnt perform the search on it, and I am a lot clueless now...

It only works if I cd $HOME/MySymlinkedPath first and remove the path reference like this find -name "run*.sh" but that is not good for my scripts...

An additional info:
this command works as usual ls $HOME/MySymlinkedPath/run*.sh, and if I go there cd $HOME/MySymlinkedPath and run this ls .. the result is not what I was expecting; the list of the path where the symlinked path is located.. it returns the list of the real path on the another media/harddrive!!!

pwd -P

Is this a problem with find and ls, or with my system? or it is expected and not a problem at all?? I am on Ubuntu 12.10. It fails on all terminals I tested so doesnt seems a terminal "problem".

share|improve this question

Here is the answer. But that question points to bash as the target of the problem.

The explanation is that find finds "$HOME/MySymlinkedPath". It's a symbolic link, not a directory, so the recursive descent stops there. If the expression matched "$HOME/MySymlinkedPath" (for example, in find "$HOME/MySymlinkedPath" -name 'My*'), then find would print that as a match.

As pointed there, I found that the easiest/cleanest way to deal with it and fix all scripts is, instead of:

find "$HOME/MySymlinkedPath" -name "run*.sh"

just add a slash, so that find starts not from the symbolic link but from the target of the symbolic link:

find "$HOME/MySymlinkedPath/" -name "run*.sh"

Alternatively, pass the -H option to find (note that it must come first, before the paths) to tell it to traverse symbolic links passed on its command line. (This is different from -L which tells find to traverse symbolic links encountered during the recursive descent as well.)

find -H "$HOME/MySymlinkedPath" -name "run*.sh"

And finally it worked best here with -L (because of the several filesystems I have symlinked thru folders). But it generates loads of non problematic error messages so I added 2>/dev/null; and also decided to create this alias alias find='find -L':

find -L "$HOME/MySymlinkedPath" -name "run*.sh" 2>/dev/null
share|improve this answer
IMHO, it's generally good practice to use a trailing slash after directories to indicate that they're actually directories. :) Makes things more readable, etc. – dannysauer Oct 6 '13 at 21:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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