Dave's Brain

Browse - computer tips - linux multiple stars

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

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

A.  For years I compose "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.
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, 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.
Advertisements: