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".
You can use the
find
command:Example:
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
).To avoid all of the "Permission denied" results, you can use:
See this article on null device and this one on standard streams for more info.
You can pipe the output to
grep
to have it highlight the directory nameSomething like
The
/
indicates to search the whole computerAn 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 tofind
as well.Another way to do this is to use
ls -laR | egrep ^d
.And the
locate
command also comes in handy:locate string