Search code examples
linuxcommand-linezip

Fill in command input


I'm trying to enter input without typing anything I'm trying to put the input in the command.

I've seen people try this:

printf 'argument\n' | command

Or

command <<< "argument\n"

I don't know if what I'm doing is command specific but neither of these work for what I'm trying to do.

I'm trying to zip a file with a password:

zip -r -e test.zip test_zip/

-e is for password input (this isn't the part I was talking). I set the password to test1234.

When I unzip the file I try things like this:

printf 'test1234\n' | unzip test.zip

But it still asks for password input.

Any suggestions?


Solution

  • Use the -P argument

    unzip -P <password> <zipfile>