簡體   English   中英

如何在同上源中包含多個文件

[英]How to include multiple files in ditto source

這似乎可以在男子同上的問題中找到,但是我已經讀過這個問題,並用谷歌搜索了這個問題,沒有答案。

我只想使用ditto歸檔一些文件,如下所示:

ditto -ckv file1 file2 file3 newfile.zip

似乎同上允許多個源文件。 但是我得到一個錯誤。

有沒有人有辦法做到這一點,或者您能確認同上不允許這樣做嗎?

更新的答案

您可以使用內置的zip命令來做到這一點:

zip archive.zip file1 file2 file3

或者,更簡單地說:

zip archive.zip file[123]

原始答案

您可以使用7zip做到這一點。


在這里,我將3個文件寫入(添加)到存檔中:

7z a archive.zip file1 file2 file3

現在,我檢查其中的內容:

7z l archive.zip 

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,8 CPUs x64)

Scanning the drive for archives:
1 file, 2827 bytes (3 KiB)

Listing archive: archive.zip

--
Path = archive.zip
Type = zip
Physical Size = 2827

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2017-06-19 21:48:35 .....         1684          811  file1
2017-06-19 21:48:39 .....         1690          813  file2
2017-06-19 21:48:41 .....         1696          815  file3
------------------- ----- ------------ ------------  ------------------------
2017-06-19 21:48:41               5070         2439  3 files

我同樣可以使用unzip檢查內容:

unzip -l archive.zip 

Archive:  archive.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1684  06-19-2017 21:48   file1
     1690  06-19-2017 21:48   file2
     1696  06-19-2017 21:48   file3
---------                     -------
     5070                     3 files

我使用以下方法通過自制軟件安裝了7zip

brew install p7zip

該手冊建議只有一個源文件系統對象可以創建一個存檔。

ditto -c [-z | -j | -k] [-v] [-V] [-X] [<options>] src dst_archive

要復制多個文件,您可以將文件或硬鏈接文件復制到目錄中,然后使用ditto壓縮目錄。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM