Any way to see output of pv when run in subshell?

ma flag

I'm creating a squashfs file using dd to create a pseudo file - like described here ("under Streaming Compression" heading):

mkdir empty-dir
mksquashfs empty-dir squash.img -p 'sda_backup.img f 444 root root dd if=/dev/sda bs=4M'

But I would like to see the progress of how much of the drive has been copied, eg like this would:

dd if=/dev/sda bs=4M | pv > sda_backup.img

It's similar in my mind to if I was trying to verify that an image was taken correctly:

cmp <(dd if=/dev/sda | pv) <(cat sda_backup.img)

In this case I don't see the output from pv.

Is there a way to see the output from pv in the subshell?

in flag

Why not use the native dd progress counter ; the status=progress flag?

dd if=/dev/sda bs=4M status=progress

which should show periodic updates like:

2051014656 bytes (2.1 GB) copied, 15.602310 s, 131 MB
localhost avatar
ma flag
Although I am surprised that actually works, and thanks for that, but I'd also like to know how to get `pv` to work for my own understanding and the use of other commands in subshells.
localhost avatar
ma flag
I don't really understand why `status=progress` works but `pv` doesn't - what is different between how they are outputting the progress messages?
HBruijn avatar
in flag
I have no idea but I think the root might be that mksquashfs expects a programme to run and shell constructs simply don’t get interpreted as such
I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.