2013-10-03 58 views
0

我有一個包含同一文件的不同版本的tar文件,如何提取文件的先前版本(不是最後一個版本)之一?提取存儲在tar歸檔文件中的以前版本的文件

這裏是如何創建一個測試tar文件:

創建一個測試目錄

[email protected]:~/tmp$ mkdir test 

創建一個測試文件

[email protected]:~/tmp$ echo line 1 > test/test.txt 

創建焦油包含測試的文件文件

[email protected]:~/tmp$ tar -cvf test.tar test/* 

回報

test/test.txt 

更改

[email protected]:~/tmp$ tar -dvf test.tar test/* 

回報(沒有評分)

012檢查

變化的測試文件

[email protected]:~/tmp$ echo line 2 >> test/test.txt 

檢查更改

[email protected]:~/tmp$ tar -dvf test.tar test/* 

回報(魔術:該文件已更改)

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

更新tar文件

[email protected]:~/tmp$ tar -uvf test.tar test/* 

回報

test/test.txt 

更改

[email protected]:~/tmp$ tar -dvf test.tar test/* 

返回檢查(兩個版本存在)

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

謝謝, 塔爾

回答

0

解決:

--occurrence =正

N - [0 ..版本的數目]

  • 0 - 最後一個(默認)
  • 1 ..的版本號 - 是版本
  • 錯誤accure實際數目如果n是較大然後版本數

例如

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

謝謝, Tal

相關問題