Daniel@0: #!/usr/bin/env bash Daniel@0: # Insert rptlen into a pipeline to report the number of bytes passing through. Daniel@0: # NB. if the pipeline is terminated early by a later consuming process, the Daniel@0: # byte count will be wrong. Daniel@0: function buflen { Daniel@0: len=$(length) Daniel@0: echo "$1:" $len Daniel@0: } Daniel@0: function buflen2 { Daniel@0: length | sed -e "s/^/$1:/" Daniel@0: } Daniel@0: tee >(buflen2 "$1" 1>&2)