[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Feature request for wc: add -v option to print total counts every second
From: |
Sina Siadat |
Subject: |
Feature request for wc: add -v option to print total counts every second. |
Date: |
Fri, 11 Mar 2016 13:40:13 +0330 |
Hi everyone,
As my first contribution, I wrote a patch (submitted a few minutes ago) for wc
to write the live total counts every second when processing large inputs that
take a long time. It is inspired by -v in tcpdump when writing the packets to a
file.
The live counts are written in the same format as the final total counts. These
counts are written to stderr, and overwritten by the final counts (i.e., when
the command stops use does not see the live counts unless stdout was
redirected).
To see it in action pipe a long running command (more than 1 second) to wc,
e.g.:
find ~ | wc -v
ping -c5 4.2.2.4 | wc -v
yes | wc -vl
A couple of issues to discuss:
- chars is not incremented at the moment, it looks like this is by design and
chars count is just copied from bytes count. Let me know if I should do the
same, i.e., live_total_chars and live_total_bytes should be equal.
- because it is the total counts for all files, there will always be 1 line of
live total counts. It is possible to write nfiles+1 lines (just like the final
complete results) because we know the number of files and I can move the cursor
up using something like "\033[nfilesA". In my opinion, the total counts is
sufficient and I thought it would be a better idea to keep this patch as small
as possible.
Thanks,
sina
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Feature request for wc: add -v option to print total counts every second.,
Sina Siadat <=