以无人参与模式解压缩文件


16

当我使用Linux机器上的unzip命令并且ZIP下的文件已存在于我的本地目录中时,我得到了交互式问题:(如果我想用ZIP机器上的现有文件替换ZIP中的文件

如何在没有此交互式问题的情况下使用unzip命令?

 [@superuser]# ls -ltr

 total 0
 -rw-r--r--    1 root     root            0 Nov 15 15:13 all_my_files1
 -rw-r--r--    1 root     root            0 Nov 15 15:13 all_my_files2

[@superuser]# unzip MY_FILES.zip

    Archive:  MY_FILES.zip
    replace all_my_files1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
        inflating: all_my_files1.txt  
        inflating: all_my_files2.txt  

Answers:


21

由于unzip(1l)男子页指出,通过-ounzip以迫使现有的文件覆盖而不提示。


警告:zip注释会提示您按Q或任何其他键继续并挂起执行。我提出避免它的唯一方法是通过,-q但这也会导致解压缩不显示解压缩的文件列表。
Artem Russakovskii

8

你想要的-o选择:

unzip -o MY_FILES.zip

资源

在没有提示的情况下覆盖现有文件。这是一个危险的选择,所以要小心使用它。(但它通常与-f一起使用。)

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.