unzip
命令本身沒有直接的選項來排除特定文件,但你可以使用 -x
選項(即 exclude)來指定要排除的文件
unzip -x "file_to_exclude.txt" archive.zip -d destination_directory
這將解壓 archive.zip
中的所有文件到 destination_directory
,但會排除名為 file_to_exclude.txt
的文件。
如果你想排除多個文件,可以在 -x
選項后列出它們,用空格分隔:
unzip -x "file1_to_exclude.txt file2_to_exclude.txt" archive.zip -d destination_directory
此外,你還可以使用通配符(如 *
)來排除特定類型的文件。例如,要排除所有 .txt
文件,可以使用以下命令:
unzip -x "*.txt" archive.zip -d destination_directory
請注意,這些示例適用于 Unix/Linux 系統。在 Windows 上,你需要使用雙引號而不是單引號,并且可能需要使用反斜杠(\
)作為路徑分隔符。