2

I have a tar file which contain different versions of the same file, how can I extract one of the previous version of the file (not the last version) ?

here is how to create a test tar file:

create a test directory

tal@backup:~/tmp$ mkdir test

create a test file

tal@backup:~/tmp$ echo line 1 > test/test.txt

create the tar file which contains the test file

tal@backup:~/tmp$ tar -cvf test.tar test/*

returns

test/test.txt

check for changes

tal@backup:~/tmp$ tar -dvf test.tar test/*

returns (nothing yet)

test/test.txt

change the test file

tal@backup:~/tmp$ echo line 2 >> test/test.txt

check for changes

tal@backup:~/tmp$ tar -dvf test.tar test/*

returns (magic: the file has changed)

test/test.txt
test/test.txt: Mod time differs
test/test.txt: Size differs

update the tar file

tal@backup:~/tmp$ tar -uvf test.tar test/*

returns

test/test.txt

check for changes

tal@backup:~/tmp$ tar -dvf test.tar test/*

returns (both versions exist)

test/test.txt
test/test.txt: Mod time differs
test/test.txt: Size differs
test/test.txt

Thanks, Tal

tals
  • 63
  • 5

1 Answers1

3

Solved:

--occurrence=n

n - [0 .. number of versions]

  • 0 - last one (default)
  • 1 .. number of version - is the actual number of version
  • error occur if n is larger then number of versions

example

tar -xvf test.tar --occurrence=1 test/test.txt

Thanks, Tal

Ethan Furman
  • 63,992
  • 20
  • 159
  • 237
tals
  • 63
  • 5