Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: less with subprocess



On 2021-10-01 00:46:12 +0100, Dominik Vogt wrote:
> On Thu, Sep 30, 2021 at 10:59:25PM +0200, Pier Paolo Grassi wrote:
> > writing on disk it can eat away all the space I have on my device and make
> > other processes that need that disk space to fail. Even if disk is cheap
> > doesn't mean it's always plentifully available
> 
> If you don't want to consume disk space you could use a
> ramdisk/tmpfs for the temporary files.

which can be worse (RAM is often more limited than disk space).

> Less will gobble up memory anyway if it gets tons of input, unless
> you give it the -b or -B option.)

No, not if one doesn't read data past some line.

For instance, I often pipe the output of "svn log" to "less", and
I generally read only the beginning to some point (not known in
advance). So, in practice, "less" will take a few dozens of KB
and avoid useless network transfers (since the log typically
comes from a remote server).

I think I've also run "less" on infinite loops ("while true; ...").

> On the other hand I wonder what kind of command would generate an
> awful lot of output quickly which can still be overlooked manually
> in less.  I mean, if you're only interested in the first N lines
> or M bytes, you can pipe the command's output through "head -n N"
> or "head -c M".

But with a pipe, "less" does that for you, automatically, and you
don't have to guess N or M. That's much better!

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Messages sorted by: Reverse Date, Date, Thread, Author