[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: listing files with spaces, using wildcard



bruce wrote:
> 
> hey...
> 
> here's one i can't see..
> 
> 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
> 
> i'm trying to figure out 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.
> 
> thoughts/pointers/etc...
> 
> thanks

You gotta go at it indirectly.

Assuming you've got a directory (or directory structure) like:
    > test=> ls -l
    > total 0
    > -rw-r--r-- 1 sos users 0 2009-02-20 01:55 1foo_ aa_bb_cc.dog
    > -rw-r--r-- 1 sos users 0 2009-02-20 01:55 2foo_aa_bbbb_cc.dog
    > -rw-r--r-- 1 sos users 0 2009-02-20 01:55 3foo_aa_bb _ccc.dog
    > -rw-r--r-- 1 sos users 0 2009-02-20 01:55 4foo_aa_bb_cc.dog
    > -rw-r--r-- 1 sos users 0 2009-02-20 01:56 5foo_aa_bb_cc.dog
    > -rw-r--r-- 1 sos users 0 2009-02-20 01:56 6foo_aa_bb_cc.dog
    > -rw-r--r-- 1 sos users 0 2009-02-20 02:04 dog__
    > -rw-r--r-- 1 sos users 0 2009-02-20 02:02 dogfood
    > -rw-r--r-- 1 sos users 0 2009-02-20 02:04 foo__
    > -rw-r--r-- 1 sos users 0 2009-02-20 02:02 foodog

Then the following pipe ought to give you what you're looking for:
    > test=> find . -print | egrep ' |_' | grep foo | grep dog
    > ./1foo_ aa_bb_cc.dog
    > ./5foo_aa_bb_cc.dog
    > ./6foo_aa_bb_cc.dog
    > ./2foo_aa_bbbb_cc.dog
    > ./4foo_aa_bb_cc.dog
    > ./3foo_aa_bb _ccc.dog
    > test=> 

Should you wish to further process that file-list by extending the
pipe, you'll need to surround the filenames with single quotes.

Hope this helps'ildy,

-S


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]