listing files with spaces, using wildcard

Bill Crawford billcrawford1970 at gmail.com
Fri Feb 20 11:45:26 UTC 2009


On Friday 20 February 2009 01:44:27 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...

Depends a little on what you want to do with the list :o)

If you need it quoted, something like:

    for file in *foo*.dog ; do
        echo "\"$file\""
    done

might help you, but that'll still fail horribly if there are any embedded quotes 
in the files. I see someone's already replied with the find ... -print0 method.




More information about the fedora-list mailing list