Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to find a directory named 480debugerror nested under child directories. I don't know the exact path, or even if I have the exact spelling of the directory I want to find.

Is there a Linux command to find directories with a given prefix or suffix, for example directories with a name of "debug" or "debug error", with some prefix or suffix that is unknown?

share|improve this question

migrated from stackoverflow.com Jan 22 '11 at 10:19

This question came from our site for professional and enthusiast programmers.

2  
You can try locate (locates files) or find (finds files). –  miku Jan 21 '11 at 13:31
    
find -type f -name *ummy... but not get –  Bharanikumar Jan 21 '11 at 13:32
2  
You need -type d. f searches for files –  thkala Jan 21 '11 at 13:34
add comment

3 Answers

find is what you need:

$ find -type d -name '*debugerror*'

or

$ find -type d -name '480debugerror'

if you are certain about the folder name.

share|improve this answer
add comment
find . -type d \( -iname '*error*' -o -iname '*debug*' \) 
share|improve this answer
add comment
locate -i "480debugerror"

will check a database that lists all the files indexed on your PC. I often have scenarios like this and so I do searches like:

locate -i "debug" | grep -i "log"

which finds all files that have in their path (regardless of case [that's what -i means]) "debug" and "log" (In case you don't know, the | grep means search within the results that locate produces)

The advantage to using locate over find is that locate will produce output much faster (since it's only checking a database) but if the file/folder is not indexed then it will not find anything. (to update the database you can use sudo updatedb)

share|improve this answer
    
Only if you have slocate installed. Some production environment does not :-( –  Zsolt Botykai Jan 21 '11 at 14:28
    
True but if an option I would say it's superior to find... –  j3frea Jan 21 '11 at 14:47
add comment

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.