To: [email protected]
Date: Wed, 24 May 2006 18:13:24 +0200
Subject: Re: [newbie] Find and spaces in file names ... was oowriter2
On Wednesday 24 May 2006 03:29 pm, Neill Jones wrote:
> Just for info and clarity:
>
> A minor extra to H.J.Bathoorns post ... in the above, it is not the
> -iname which causes
> problems with the spaces, it is the use of xargs. For example,
>
> find . | grep "filename"
>
> works as pointed out by Harm. Also
>
> find . -iname "*.txt" | grep "filename"
>
> will work with all .txt files found. In both cases this can be
> understood since find returns
> each find item with a new line after it. grep then just reads each line
> of standard in which
> is a full line with the file name on it. When these are combined
> together as parameters for
> xarg however the spaces are seen as parameter breaks and so cause
> problems. Then you need
> to use the -print0 and xargs -0 options.
Reading theman-pages one would expect so but ....... on none of my boxes do
filenames with spaces get shown using -iname, either with or without print0
and/or xargs -0.
Do they show up on your box or are you asuming they will?
>
> A minor extra to H.J.Bathoorns post ... in the above, it is not the
> -iname which causes
> problems with the spaces, it is the use of xargs. For example,
>
> find . | grep "filename"
>
> works as pointed out by Harm. Also
>
> find . -iname "*.txt" | grep "filename"
>
> will work with all .txt files found. In both cases this can be
> understood since find returns
> each find item with a new line after it. grep then just reads each line
> of standard in which
> is a full line with the file name on it. When these are combined
> together as parameters for
> xarg however the spaces are seen as parameter breaks and so cause
> problems. Then you need
> to use the -print0 and xargs -0 options.
Reading theman-pages one would expect so but ....... on none of my boxes do
filenames with spaces get shown using -iname, either with or without print0
and/or xargs -0.
Do they show up on your box or are you asuming they will?
Maybe I am not understanding very well, when I want to combine find and grep I type :
find /whereever -type f -exec grep -H "pattern" {} \;
It does show filenames with spaces.
