[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: cat and pipelines, mostly (was Re: Delete all after a pattern)



On Sat, Aug 31, 2019 at 06:49:38PM -0500, David Wright wrote:
> Exactly; so
>     cat afile | some-filter …
> is just the degenerate of the general case
>     cat somefiles* | some-filter …
> where there happens to be only one filename matching somefiles*.
> So if you start prototyping some complicated command line by typing
> for example:
> 
> cat some-directory/… |
> 
> you don't have to think about whether said directory might contain a
> single file or several, and instead just concentrate on the problem
> in hand, after the pipe.

For interactive use, this is fine.  It would be pointless to spend 60
seconds optimizing a one-time interactive command to make it run 60
milliseconds faster.

For scripts, however, one expects to run the script more than once, and
one expects the script to have correct behavior.[1]  So, a bit of
effort spent writing it properly is well invested.

[1] I speak hypothetically, of course.  In real life, I expect every
    shell script I encounter to be complete shit.  Most especially any
    script that's part of a commercial product.


Reply to: