Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Suppose I have the directories:

/foo/
/A/B/C/foo/D/E/
/F/foo/G/H/foo/I/

How can get a result that lists all the directories whose basename exactly matches a given string (for example foo in here)?

/foo/
/A/B/C/foo/
/F/foo/
/F/foo/G/H/foo/
share|improve this question

1 Answer 1

up vote 10 down vote accepted

You can use find:

$ find / -type d -name foo -print
share|improve this answer

Your Answer

 
discard

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.