I have a tape with multiple tar files on it. I do not know how many (it was created by a third party and sent to me with minimal information). How do I untar all the files without having to repeat the tar -xvf /dev/st2 command 100 times. I need to repeat this for 45 tapes, each with possibly a 100 files
migrated from stackoverflow.com Oct 30 '12 at 22:56
This question came from our site for professional and enthusiast programmers.
If the tape drive has a non-rewinding interface you can use a loop to extract one file after another.
Typical examples of tape drive name are:
This can be combined with the exit code from tar. Like all unix program exit code 0 means "success, no problems."
This you can use a somewhat ugly one liner in a shell:
Or write a somewhat neater program: