I do unzip my.zip and if files already exists it asks replace myfile.ext [y]es, [n]o, [A]ll, [N]one, [r]ename:

How can I force input for when the command prompts for input? I am aware unzip may have force flag but I am interested in passing an input.


I think you're looking for the yes command :

yes | unzip my.zip

It sends y to the output again and again. If you want to send something else, specify it as the argument:

yes n | unzip my.zip

You can also use echo if there's only one question:

echo no | unzip my.zip
| improve this answer | |

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.