Possible grep(1) bug or user error :)?

Garrett Cooper youshi10 at u.washington.edu
Sat Mar 17 23:09:25 UTC 2007


James Bailie wrote:
> Garrett Cooper wrote:
>  > grep -ri {key} * > {key}.found
>  >
>  > The thing is that grep kept on feeding off of the {key}.found file and
>  > eventually ate up all the free space on the device (~12GB).
> 
> The shell is redirecting stdout onto the found file before it is
> expanding the glob patterns, so the found file is being included
> in the expansion.  You can force the expansion to occur first if
> you assign it to a variable:
> 
> sh:
> 
> FILES=*; grep -ri key $FILES > found
> 
> csh:
> 
> set FILES=*; grep -ri key $FILES > found
> 
> Hope this helps,

Thanks James :). That's another good solution for working around that.

-Garrett



More information about the freebsd-hackers mailing list