1

So I had this question earlier and it got answered "Terminal - Zip multiple directories into separate zip files with password" however I couldn't find out how I can use a password with special characters like !@#$. I tried the typical solutions:

  • Enclose the whole password string in " " or ' '
  • / before every special character.

Nothing worked. This is the command that worked for me except that the password was never set correct (in my attempts it was either set to something different from what I intended, or wasn't set all together)

for i in */; do zip -r "${i%/}.zip" "$i" -p "mypassword!@#$" ; done
  • Did you try / or \ ??? – Luciano Andress Martini Jun 16 '17 at 20:26
  • \ I believe. Which one is the correct? – Tarek Jun 16 '17 at 20:33
  • The correct is this form \ please edit your answer, and make sure you are using the correct form.... do you used the zip command to make the password too? Maybe some character are not really included at the password (being ignored at the compression utility), so you can try without some of it. The right way is something like this: mypassword\!\@\#\$ – Luciano Andress Martini Jun 16 '17 at 20:34
  • Did you try using 'strong quotes' rather than "weak quotes" around the password? Alternatively, put the password into a variable and use -p "$password". – DopeGhoti Jun 16 '17 at 20:54
  • @LucianoAndressMartini Worked well. Not sure what was wrong earlier. You can go ahead and reply to my question as an answer so I can pick it. – Tarek Jun 16 '17 at 20:55
1

You are probably using "/" instead of "\", so the right solution will be like this:

 mypassword\!\@\#\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.