Shell – How send multiple command as input in a program

command lineinputshell

I know how send a command as a input in a program like this:

echo toto | ./my_prog

And with process substitution + redirection:

r < <(echo toto)

But how to do this if I want to input a second or a third input?

For example, I have a program that ask my username first and after this it ask me others informations like a number phone or whatever in different input.

Best Answer

Use { and } to collect the output of multiple programs. For instance, { echo one; echo two; } |program. Leave a space after { and before } and ensure there is a semicolon after the last command within the braces.

Related Question