Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Mar 2007 18:21:09 -0400
From:      James Bailie <jimmy@mammothcheese.ca>
To:        Garrett Cooper <youshi10@u.washington.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Possible grep(1) bug or user error :)?
Message-ID:  <45FC69D5.3010406@mammothcheese.ca>
In-Reply-To: <45FC61FF.3090009@u.washington.edu>
References:  <45FC61FF.3090009@u.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
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,

-- 
James Bailie <jimmy@mammothcheese.ca>
http://www.mammothcheese.ca



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45FC69D5.3010406>