user2233125
user2233125

Reputation:

Strange behaviour of UNIX find command

OK this might be silly, but it's really annoying.

I've been experiencing trouble with find lately and I can't figure out what the problem is. Basically I'm trying to find a folder called bin that I know must be inside another folder called lib. For this, I use the following command.

find * -type d -wholename "lib/bin"

This effectively finds the folder I'm looking for, but only if I am in the directory containing lib. If I move one directory up, i.e.

cd..

the same command above will return nothing.

I know that find automatically searches recursively, so I don't understand why it can't find my directory in the second case. Any ideas?

Upvotes: 0

Views: 108

Answers (1)

Dummy00001
Dummy00001

Reputation: 17420

The -wholepath, as name implies, matches the whole name of the element. See man find for the description of the -path option (which has made the -wholepath obsolete).

What you want is something like this:

find ./* -type d -path "*/lib/bin"

Upvotes: 2

Related Questions