[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request: --progress option to wc(1) - [Solved] [Accepted]
From: |
Joakim Lindblad |
Subject: |
Re: Feature request: --progress option to wc(1) - [Solved] [Accepted] |
Date: |
Sat, 16 Nov 2024 18:53:04 +0100 |
User-agent: |
Mozilla Thunderbird |
Fair enough Pádraig.
Felt it was a bit overkill/overcomplex with pv, but it does solve the problem.
With a bit of string processing (irritatingly pv does not combine -F format
with -n plain integer output).
This is my solution (with sed to prepend '\r' and tr to eat '\n' and echo to
add a '\n' at the very end) :
tar -tf big.tar | pv -i 0.1 -lbnX 2>&1 | stdbuf -o0 sed -e 's/^/\r/' | stdbuf
-o0 tr -d '\n'; echo;
A small timing test on 1,000,000,000 lines shows that the overhead is
negligible (and I learnt that 'seq' is significantly slower than 'yes | head')
$ time { yes | head -n 1000000000 >/dev/null ; }
real 0m1,976s
user 0m1,539s
sys 0m1,155s
$ time { yes | head -n 1000000000 | wc -l ; }
1000000000
real 0m2,545s
user 0m2,043s
sys 0m2,359s
$ time { yes | head -n 1000000000 | pv -i 0.1 -lbnX 2>&1 | stdbuf -o0 sed -e
's/^/\r/' | stdbuf -o0 tr -d '\n'; echo; }
1000000000
real 0m2,649s
user 0m3,889s
sys 0m2,085s
Cheers!
/ Joakim
On 2024-11-15 17:57, Pádraig Brady wrote:
On 15/11/2024 15:40, Joakim Lindblad wrote:
I'm often using 'wc' for stuff that takes a long time, e.g. 'tar -tf big.tar |
wc -l' to count the
files in an archive.
Here I am lacking some intermediate feedback from the process.
Does a "--progress" version of 'wc' exist? I am envisioning a continuous count
with a simple
line-wise overwrite a'la '\r'.
I fail to find the option, and I don't find the feature request rejected
https://www.gnu.org/software/coreutils/rejected_requests.html#wc
I could potentially volunteer to implement it (but am happy not to).
Yes this does seem like useful functionality,
however it's already implemented in `pv --line-mode`,
so I don't see an advantage to implementing in wc.
For example:
while :; do seq 10; sleep 1; done | pv --line-mode > /dev/null
thanks,
Pádraig
VARNING: Klicka inte på länkar och öppna inte bilagor om du inte känner igen
avsändaren och vet att innehållet är säkert.
CAUTION: Do not click on links or open attachments unless you recognise the
sender and know the content is safe.
--
_______________________________________________________________
Joakim Lindblad, PhD, Docent E-mail:
joakim@cb.uu.se<mailto:joakim@cb.uu.se>
Prof. Computerized Image Processing Phone: +46-733-168549
Dept. of IT, Uppsala University http://cb.uu.se/~joakim
_______________________________________________________________
När du har kontakt med oss på Uppsala universitet med e-post så innebär det att
vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du
läsa här: http://www.uu.se/om-uu/dataskydd-personuppgifter/
E-mailing Uppsala University means that we will process your personal data. For
more information on how this is performed, please read here:
http://www.uu.se/en/about-uu/data-protection-policy