On 08/09/2020 10.49, J Leslie Turriff wrote:
On 2020-09-07 07:35:30 Carlos E. R. wrote:
Hi,
I have this line to image a disk partition and compress it:
dd if=/dev/nvme0n1p2 status=progress bs=16M | pigz > nvme0n1p2.gz
How could I insert in the pipe the md5 calculation of the non-compressed stream, stored to a file? Is it possible?
I know I can use "tee" to pipe and create a file, but that is not it.
The info file for tee shows how to do this.
Does it? Gosh, I read it time ago. [...] Yes, it does :-o # slightly contrived, to demonstrate process substitution wget -O - https://example.com/dvd.iso \ | tee >(sha1sum > dvd.sha1) > dvd.iso ... «Note, however, that this example relies on a feature of modern shells called “process substitution” (the ‘>(command)’ syntax, above; *Note Process Substitution: (bash)Process Substitution.), so it works with ‘zsh’, ‘bash’, and ‘ksh’, but not with ‘/bin/sh’. So if you write code like this in a shell script, be sure to start the script with ‘#!/bin/bash’.» ... You can extend this example to make ‘tee’ write to two processes, computing MD5 and SHA1 checksums in parallel. In this case, process substitution is required: wget -O - https://example.com/dvd.iso \ | tee >(sha1sum > dvd.sha1) \ >(md5sum > dvd.md5) \ > dvd.iso Well, well... -- Cheers / Saludos, Carlos E. R. (from 15.1 x86_64 at Telcontar)