想用密码保护我的 ZIP 存档。
用这个创建存档:
zip -er archivename.zip file
得到这个:
Enter password:
Verify password:
一切正常,但我有密码变量,需要将此密码发送到 zip
。尝试过这样的论点,但失败了。
echo "$1"| zip -er archivename.zip file
在 bash 中可以吗?因为 zip 实用程序不支持 stdin
。
最佳答案
读人
对于不安全的解决方案,使用-P
:
-P|--password password Use password to encrypt zipfile entries (if any). THIS IS INSECURE!
用户互动
-e|--encrypt Encrypt the contents of the zip archive using a password which is entered on the terminal in response to a prompt
关于bash - stdin 到 zip 命令而不是提示符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20496331/