Sie können tar dazu auffordern, alle paar Blöcke eine Aktion an den Kontrollpunkten auszuführen . Mit dieser Aktion kann getestet werden, ob die gewünschte Datei extrahiert wurde, und wenn dies der Fall ist, beenden Sie den Teer. Ich habe es mit einer tar-Datei ausprobiert und es scheint ok zu funktionieren.
Hier ist mein Beispielskript, um meinen Test durchzuführen, / usr / bin zu tarieren und usr / bin / bash in / tmp / usr / bin / bash zu extrahieren. Der Standardwert --checkpoint ist 10 Blöcke.
#!/bin/bash cat <<\! >/tmp/checkdone #!/bin/bash # env has TAR_CHECKPOINT TAR_ARCHIVE TAR_VERSION TAR_BLOCKING_FACTOR # tar -C directory is NOT used for checkpoint action! want=$1 if size=$(stat --printf='%s\n' "$want" 2>&1) then if [ "$(</tmp/lastsize)" = "$size" -a -s /tmp/pid ] then echo "same size $size. time to stop" ls -l "$want" >/tmp/lastsize kill -1 $(</tmp/pid) else echo "partial size $size" echo "$size" >/tmp/lastsize fi else echo -n "." fi ! chmod +x /tmp/checkdone >/tmp/lastsize >/tmp/pid tar -cf /tmp/tar /usr/bin/ # create example tar file # wanted file. must be in current dir want=usr/bin/bash cd /tmp || exit # dont use tar -C dir tar -xvf /tmp/tar "$want" --checkpoint=10 --checkpoint-action=exec="/tmp/checkdone $want" & echo $! >/tmp/pid wait rm /tmp/tar /tmp/pid /tmp/lastsize /tmp/checkdone rm -fr /tmp/usr