Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I recursively search for directory names with a particular string where the string is only part of the directory name?

For example: the directory name is "8.0.3-99966_en", but I want to recursively search for directories with the string "99966".

share|improve this question

2 Answers 2

An easy way to do this is to use find | egrep string. If there are too many hits, then use the -type d flag for find. Run the command at the start of the directory tree you want to search, or you will have to supply the directory as an argument to find as well.

Another way to do this is to use ls -laR | egrep ^d.

And the locate command also comes in handy: locate string

share|improve this answer

You can use the find command:

find YOUR_STARTING_DIRECTORY -type d -name "*99966*" -print

Example:

find ~ -type d -name "*99966*" -print

should find all directories (-type d) starting from your home directory (~)that have their names containing the string "99966" (-name "*99966*") and output them (-print).

share|improve this answer
    
How can I exclude a certain directory from the search? I need to search / but I get tons of /proc results which I do not care about. –  Kozuch Oct 27 at 13:52

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.