JPashs
JPashs

Reputation: 13886

Command to find a folder inside folders

I need a terminal command to find all instances of a folder inside folders.

I need to find all instances folders with the name 'builder' inside the folder 'www' including all folders inside 'www'.

I tried with:

find www -path '*/builder/*' -type d > list

but nothing, no error.

Upvotes: 0

Views: 112

Answers (2)

user1934428
user1934428

Reputation: 22217

How about:

find www -name builder -type d

This will print the relative pathes (starting with www) to all folders named "builder" on standard output, one path per line.

Upvotes: 0

Inian
Inian

Reputation: 85580

Proper way of using find

find www -name "*builder*" -type d -print

(or)

find www -name "*builder*" -type d -printf "%f\n"

where a glob construct *builder* is passed as input to the -name field which searches all directories under www/ whose names have the string present.

Upvotes: 1

Related Questions