Shell-Script
終端 - 使用密碼將多個目錄壓縮成單獨的 zip 文件
所以我在這裡遵循了解決方案: command to zip multiple directory into individual zip files
我在命令中添加了-er,但是正如我所料,我需要為每個循環操作輸入密碼,即每個被壓縮的文件夾。
如何自動化密碼部分?我想對所有壓縮文件使用相同的密碼。
謝謝
編輯:如果我可以在另一個目錄中創建所有輸出 zip 文件,那就太好了
您可以使用 -P 標誌而不是 -er 標誌 - 它期望密碼跟隨。
-P password --password password Use password to encrypt zipfile entries (if any). THIS IS INSE- CURE! Many multi-user operating systems provide ways for any user to see the current command line of any other user; even on stand-alone systems there is always the threat of over-the- shoulder peeking. Storing the plaintext password as part of a command line in an automated script is even worse. Whenever possible, use the non-echoing, interactive prompt to enter pass- words. (And where security is truly important, use strong encryption such as Pretty Good Privacy instead of the relatively weak standard encryption provided by zipfile utilities.)
請注意,這是不安全的,因為密碼顯示在命令行上,並且其他人可能會看到程序樹。
如果這不可接受,請考慮使用 expect 實用程序。