I would like to show the content of a file and also the calculated cksum of the file at once, why does the following command only output the file - but not the cksum?
sudo cat filename | tee cksum
I know that I could use sth likef=filename; sudo cat $f; sudo cksum $fbut I would prefer to use tee or sth similar if possible.
2 Answers
Didn't you mean:
sudo cat filename | tee file-name | cksumTo repeat the file name, tee is not the command you want.
Try: cat filename && cksum $_
The reason why your command does not show the checksum is because you're actually writing to a file called cksum and printing it to stdout, instead of printing it to stdout and passing it on to the actual chksum command.
What you can do instead is using tee to write it to the tty file (your terminal) and use the stdout for chksum, like the following:
sudo cat filename | tee /dev/tty | cksum 1