Dave's Brain

Browse - Computer Tips - How do I find files in a bunch of subfolders?

Date: 2007nov28
OS: Linux, Unix
Keywords: glob

Q.  How do I find files in a bunch of subfolders?

A.  For years I composed "find" commands to do this sort of
thing.  For example:

cd /etc find . -name \*.conf
But check out this way of doing it:
cd /etc ls */*.conf
More compact and easier to understand. For some reason I had never thought of using multiple stars in one command. Notice that bash is smart enough to evaulate the second star in each subfolder! The find command will list .conf files in the /etc folder. While the ls doesn't. Perhaps this is what you want. Of course, find will look in a unlimited number of subfolders (unless you use -maxdepth) and the ls only looks down one. But sometimes is is exactly what you want.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.