bash - stdin 到 zip 命令而不是提示符

标签 bash unix terminal zip stdin

想用密码保护我的 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/

相关文章:

bash - 在 Bash 中增加一个全局变量

python - 内存映射会随着时间的推移而变慢,还有其他选择吗?

linux - 屏幕,断开连接时进程终止?

python - 从 python(或 bash)部分并行运行外部命令

bash - MySQL根据给定参数显示最早的重复项

unix - ssh命令-T选项

c - 如何使 printf 在 C 中正确打印用户输入 argv 的 strtok

java - 如何通过命令控制台/终端执行脚本后显示 SVG 图像?

linux - 使用 sed 在两个模式之间打印

bash - 使用 shell 脚本从具有指定条件的行中获取特定的列值