我想解压缩 .gz
文件但不覆盖。当生成的文件存在时,gunzip 将请求覆盖权限,但我希望 gunzip 默认情况下不覆盖并中止。我在一个人那里读到 -f
强制覆盖,但我没有发现任何关于跳过它的信息。
gunzip ${file}
在复制 cp -n ${file}
时我需要类似 -n
的东西
最佳答案
gunzip
会在覆盖文件之前提示您。您可以使用 yes
命令自动将 n
字符串发送到 gunzip
提示符,如下所示:
$ yes n | gunzip file*.gz
gunzip: file already exists; not overwritten
gunzip: file2 already exists; not overwritten
关于bash - 如何在不以非交互方式覆盖的情况下压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24011976/