I am using GNU tar to create multi-volume archives:
DIR=~/temp
BLOCKSIZE=500M
tar cMf multi-0001.tar --new-volume-script=volume-script.sh --tape-length=$BLOCKSIZE $DIR
I want to create a file listing that shows the contents of each volume. I have tried adding multiple --verbose options, and while that does give me a list of all the files that are being archived, it does not tell me which volume they are in.
I am aware that I could run each volume through tar again using the --list command, but I would prefer to avoid having to process all my data twice.
(For reference, the content of volume-script.sh is as follows; I do not believe it is relevant to the question
#! /bin/bash
echo multi-$(printf "%04d" $TAR_VOLUME).tar >&$TAR_FD
)
EDIT: Question withdrawn
This question contains a false assumption. It is confirmed in the answer to this followup question that --list is a perfectly acceptable way of creating index files on seekable media. My solution now looks like this:
DIR=~/temp
BLOCKSIZE=500M
tar cMf multi-0001.tar --new-volume-script=volume-script.sh --tape-length=$BLOCKSIZE $DIR
for i in *.tar;
do echo q | tar --list -M -f $i --verbose --verbose > $i.index.txt 2>/dev/null;
done