How do you bypass the password input when making a password protected zip file?

Viewed 215

I know it's possible to password protect a zip file by using -e.

$ zip -e archivename.zip directory_name

After which you have to enter a password twice in the terminal. I was wondering if it's possible to bypass that by using an alias or a function so that it would look more like this:

$ zip archivename.zip directory_name password
1 Answers
unzip -P <enter_password> filename.zip

If you want to simulate key pass for example pass = 1234 you can do this:

echo -ne "1234\n1234" | zip -e archivename.zip

\n simulate Enter

Related