How can I search through directories starting with a certain letter with the Linux find command. For example I want to search all directories starting with the letter "a" for a file or directory "b".
|
feedback
|
|
Try a find in a find: find . -type d -name "a*" -exec find {} -name "b" \;
Starting at the current directory ( If you only want it to look in the folders starting with a, and no directories in those a* folders, use maxdepth: find . -type d -name "a*" -exec find {} -maxdepth 1 -name "b" \;
to get rid of errors: find . -type d -name "a*" 2> /dev/null -exec find {} -maxdepth 1 -name "b" \;
| |||||||||||
feedback
|
|
Just a quick update for people who might end up on this question. In addition to the solution John T provided, I have also found that you can exclude directories by using the prune switch (should have read the man pages sooner I guess, hehe.) So for example if I want to search all directories for file or directory "b" except directories starting with an "a" I can do this
bing | |||
|
feedback
|