slight problem with grep.

Stanley Friesen friesen at psivax.UUCP
Thu Feb 6 04:25:31 AEST 1986


In article <140 at calma.UUCP> radzy at calma.UUCP (Tim Radzykewycz) writes:
>
>Note that this will only happen if 'zzzz' is an existing file.  If
>either of the following situations occur, there won't be a problem:
>       grep write * > AAAA             <- AAAA doesn't contain 'write'
>       rm zzzz ; grep write * > zzzz
>
>In the first situation, the file 'AAAA' is searched first.
>In the second situation, the '*' doesn't match the file 'zzzz',
>so grep never even opens it.
>--
        Actually, the second form *does not* work. The shell performs
I/O redirection *before* filemname substitution, so the file 'zzzz'
does exist and *is* included in the expansion, and grep *will* open
it. At least this is true for csh, I tried it(in a harmless way using
echo rather than grep). The first one will work because when grep
scans AAAA it will be totally empty, due to the shell opening it for
writing.
--

                                Sarima (Stanley Friesen)

UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen
ARPA: ttidca!psivax!friesen at rand-unix.arpa



More information about the Comp.bugs.4bsd.ucb-fixes mailing list