Dark's Code Dump

Possibly useful

Print tar label without reading entire tar archive

GNU Tar lacks an option to print the tar label and exit immediately – it can only print the label as part of reading the whole archive. This works ok-ish for hard disks where ctrl+c is instant and without side effects, but is unsuitable for tape drives.

The following simple perl one-liner prints the label from a tar archive passed in stdin:

cat my.tar | perl -e 'read(STDIN, $header, 100); print(unpack("Z100", $header)."\n");'

An alternative, hackier, approach is discussed in my post on LTO tape drives: https://darkimmortal.com/2018/10/adventures-with-lto-tape-for-home-casual-use/


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.