[英]tar: add all files and directories in current directory INCLUDING .svn and so on
[英]tar files including directory without siblings
我有以下文件結構
.
├── doc1.pdf
├── doc2.pdf
└── images
├── img1.jpg
└── img2.jpg
我想在tar圖像目錄中保留父images
(沒有完整的路徑)。 更重要的是,我想跳過目錄(doc1,doc2)中的其他文檔,目前我使用的是:
tar -cf /sth_dir/images.tar -C /images/ . --exclude="doc*"
但我不想使用--exclude
因為可能會在其中添加具有不同名稱的其他文件。
這應該工作:
tar cf /sth_dir/images.tar images
當我包含-v
參數( tar cvf ...
)時, tar
產生了以下輸出:
a images
a images/img1.jpg
a images/img2.jpg
tar文件的內容如下所示:
images/
images/img1.jpg
images/img2.jpg
tar cf /sth_dir/images.tar -C / images/images
假設您有一個images
目錄嵌入在另一個images
目錄中。
人焦油:
-C, --directory DIR
change to directory DIR
或者,可以考慮使用cpio
。 假設您對find
有豐富的經驗,那么您可以很具體地將要歸檔的內容。 例如,此二重奏使您可以存檔目錄而不包含目錄的內容,我發現它在許多用例中都非常有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.