With GNU tar
you can just do:
tar --totals -c . >/dev/null
...which will render output like...
Total bytes written: 5990400 (5.8MiB, 5.5GiB/s)
...on stderr. Similarly, with any tar (or stream) you can use dd
to deliver a report on byte counts. This may or may not be preferable to wc
, but dd
defaults to a block-size of 512 bytes - which is identical to tar
's block-size. If your system's PIPE_BUF is large enough, you can even expand dd
's block-size to match tar
's record size - which is 20 blocks, or 10240 bytes. Like this:
tar -c . | dd bs=bx20 >/dev/null
585+0 records in
585+0 records out
5990400 bytes (6.0 MB) copied, 0.0085661 s, 699 MB/s
This may or may not offer a more performant solution than wc
.
In both the dd
and tar
use-cases you needn't actually dispose of the stream, though. I redirect to /dev/null
above - but I could have as easily redirected to some file and still received the report on its size at the time it was written.
wc
's superfluous-
then you don't need the subsequentcut
command either. – Janis Jun 01 '15 at 02:11