listing files with spaces, using wildcard

Phil Meyer pmeyer at themeyerfarm.com
Fri Feb 20 02:07:01 UTC 2009


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 may have to do a: find ... -print0 | xargs --null

That way,  xargs will see the file names with spaces in them.



The trick is: -print0 separates file names with nulls, and xargs --null 
reads arguments separated by nulls.


Good luck!




More information about the fedora-list mailing list