I have a tar file that has been updated (e.g. tar -uf backup.tar file.txt), over time, with various iterations of a specific file (e.g. file.txt).

How can I extract an older version of the file, not the latest version?

1 Answer 1


You can use the --occurrence option:

          Process only the Nth occurrence of each  file  in  the  archive.
          This  option  is  valid only when used with one of the following
          subcommands: --delete, --diff, --extract or --list  and  when  a
          list  of files is given either on the command line or via the -T
          option.  The default N is 1.

Ex. given

$ tar tvf archive.tar
-rw-r--r-- steeldriver/steeldriver 15 2020-11-16 18:25 file
-rw-r--r-- steeldriver/steeldriver 15 2020-11-18 18:25 file
-rw-r--r-- steeldriver/steeldriver 15 2020-11-19 18:25 file


$ tar xvf archive.tar file --occurrence=2
$ ls -l file
-rw-r--r-- 1 steeldriver steeldriver 15 Nov 18 18:25 file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .