Web lists-archives.com

Re: An appropriate directory search tool?




On Sunday, October 21, 2018 02:52:15 PM David Wright wrote:
> On Sun 21 Oct 2018 at 13:11:16 (-0400), rhkramer@xxxxxxxxx wrote:
> > <quote>
> > rhk@s19:/rhk/ked1$ grep test - >| /tmp/a ; echo "and the output is" ; cat
> > /tmp/a one
> > two
> > test
> > one
> > two
> > test
> > ^C
> > rhk@s19:/rhk/ked1$ less  /tmp/a
> > rhk@s19:/rhk/ked1$
> 
> ^C is not the way to exit stdin; you should use ^D, like logging out.
> Unfortunately ^C has also lost you the contents of /tmp/a as the
> buffer wasn't flushed. (Use cat, rather than less, so we all see it.)
> In addition, if there are any filenames following - (stdin), it will
> also skip those. With ^D instead, those files will all be inspected
> in the same way, in regular order, to see if they any matching lines.
> No restarting required.

Ok, here is the new test (using ^D)::

<quote>
rhk@s19:/rhk/ked1$ grep test - >| /tmp/a ; echo "and the output is" ; cat 
/tmp/a
one 
two
three
test
one 
two
test
and the output is
test
test
rhk@s19:/rhk/ked1$ 
</quote>

> 
> > rhk@s19:/rhk/ked1$ grep -l test - >| /tmp/a ; echo "and the output is" ;
> > cat /tmp/a one
> > two
> > test
> > and the output is
> > (standard input)
> > rhk@s19:/rhk/ked1$
> 
> But now you can see that the succesful match meant that you didn't
> have to keep typing any more stdin because it was closed for you
> immediately after the match.
> 
> That's the idea of "short-circuit" operations; once a match is found
> in a file, the rest of it doesn't have to be read, however long the
> file is. That's a useful, but non-essential, efficiency.
> 
> But the warning is also necessary because you have to think about the
> process that's feeding stdin (when it's not you typing it in). That
> process might have expected stdin to remain open and writable much
> longer than it did, perhaps only closing it when *it* had finished
> doing whatever.

Thanks -- more to absorb ;-)