[CentOS] listing files with spaces, using wildcard

Sat Feb 21 12:38:52 UTC 2009
jkinz at kinz.org <jkinz at kinz.org>

Edited for brevity
On Fri, Feb 20, 2009 at 05:08:07AM -0800, bruce wrote:
> goat a bunch of files in different dirs.. the files might have spaces
>  1foo_ aa_bb_cc.dog
>  2foo_aa_bbbb_cc.dog
>  3foo_aa_bb _ccc.dog
>  4foo_aa_bb_cc.dog
>  5foo_aa_bb_cc.dog
>  6foo_aa_bb_cc.dog
> 
> ...how i can do a complete list of all files with >  *foo*dog
> so i get the files with spaces and underlines...
> i thought simply doing somehting like
> 
>  ls '*foo_*.dog' and surrounding the filename with single quotes would
> work.. but it doesn't.
Its not exactly clear what you wanted.

for a given dir  ls *foo*dog* gets them all. 

if you wanted to get only those with _ or spaces then
ls -1 | egrep '[ _]'  works

for a tree of dirs: find . -name "*foo*dog"    gets them all

if you wanted to get only those with _ or spaces then
find . -name "*foo*dog" | egrep '[ _]'  works

Jeff Kinz

-- 
"Funniest signatures series": (found posted to a public email list)

IMPORTANT: This email remains the property of the Australian Defence
Organisation and is subject to the jurisdiction of section 70 of the CRIMES
ACT 1914.  If you have received this email in error, you are requested to
contact the sender and delete the email.