Ankit Goyal Ankit Goyal - 1 month ago 7
Bash Question

How to pass consecutive multiple arguments and enter to a command inside shell script?

I have created a simple shell script. In this script one command require user input as 1 1 1 ENTER ENTER ENTER ENTER etc.

How can i pass these user inputs to script?

Regards,
Ankit

Answer

If you want to pass three lines consisting of the string "1" followed by an arbitrary number of blank lines to the command cmd, you can do:

yes "" | sed -e 1,3s/^/1/ | cmd
Comments