Ankit Goyal Ankit Goyal - 1 year ago 74
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?


Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download