Pobe
Pobe

Reputation: 2793

tar and tee command, md5sum on the fly

Why is creating an archive like :

tar -p -c -f - --acls file1 | tee mybackup.tar | md5sum

give a different checksum than doing md5sum on this same archive, doing :

tar --to-command=md5sum -x -f mybackup.tar (This is the same as tar -x -f mybackup.tar -O | md5sum)

The objective here is to catch md5sum on stdout while doing the archiving. Avoiding me to "dry-run" a tar only for md5sum.

Upvotes: 1

Views: 1730

Answers (1)

Pobe
Pobe

Reputation: 2793

Doing tar --to-command=md5sum -x -f mybackup.tar md5sums the extracted files, not the tar archive itself.

Doing cat mybackup.tar | md5sum is the right way to compare the checksum.

Upvotes: 3

Related Questions