Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

find /bin -iname 'sh*' doesn't return any result

Writer Sophia Terry

The question is about the syntax of find command

me@222:~$ find /bin -iname 'sh*'

doesn't return any result, while:

me@222:/bin$ find -iname 'sh*'

works fine

setup info: using putty from windows to remote into ubuntu 20 LTS.

Also:
I would like to request for a syntax to properly see exactly what find is doing. for example, the files it is traversing thru, the exact path or filename string it is trying to match against, etc.

3

1 Answer

On recent Ubuntu systems, /bin is a symbolic link to /usr/bin as a result of usrmerge, and the find command does not follow symlinks by default. From man find:

 -P Never follow symbolic links. This is the default behaviour. When find examines or prints information a file, and the file is a symbolic link, the information used shall be taken from the properties of the symbolic link itself. -L Follow symbolic links. [...] -H Do not follow symbolic links, except while processing the com‐ mand line arguments. When find examines or prints information about files, the information used shall be taken from the prop‐ erties of the symbolic link itself. The only exception to this behaviour is when a file specified on the command line is a sym‐ bolic link, and the link can be resolved. For that situation, the information used is taken from whatever the link points to (that is, the link is followed). The information about the link itself is used as a fallback if the file pointed to by the sym‐ bolic link cannot be examined. If -H is in effect and one of the paths specified on the command line is a symbolic link to a directory, the contents of that directory will be examined (though of course -maxdepth 0 would prevent this).

You probably want

find -H /bin -iname 'sh*'

or

find /usr/bin -iname 'sh*'

to follow the /bin symlink but retain the default behavior below that.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy