I'm trying to look through this: How do I get the MD5 sum of a directory's contents as one sum?, and so I'm trying:
$ find | LC_ALL=C sort | cpio -o | md5sum
25324 blocks
6631718c8856606639a4c9b1ef24d420 -
Hmm... I'd like just the hash, not anything else in the output... so assuming that "25324 blocks" has been printed to stderr, I try to redirect stderr to /dev/null
:
$ find | LC_ALL=C sort | cpio -o | md5sum 2>/dev/null
25324 blocks
6631718c8856606639a4c9b1ef24d420 -
Nope, that's not it. Let's just for tests sake, try to redirect stdout to /dev/null
:
$ find | LC_ALL=C sort | cpio -o | md5sum 1>/dev/null
25324 blocks
Ok, so the hash is gone as expected - but the "blocks" message is still there ?! Where the hell is this "25324 blocks" printed, via file descriptor 3 ?!:
$ find | LC_ALL=C sort | cpio -o | md5sum 3>/dev/null
25324 blocks
6631718c8856606639a4c9b1ef24d420 -
Nope, that's not it... In any case, I can get just the hash with awk:
$ find | LC_ALL=C sort | cpio -o | md5sum | awk '{print $1}'
25324 blocks
6631718c8856606639a4c9b1ef24d420
but still the darn "blocks" message is printed... So how is it printed to terminal at all (as it seems not printed via either stdout or stderr), and how can I suppress that message?
EDIT: found the answer, the "blocks" message is printed by cpio
actually, so the right thing to do is:
$ find | LC_ALL=C sort | cpio -o 2>/dev/null | md5sum | awk '{print $1}'
6631718c8856606639a4c9b1ef24d420
Now we have just the hash...