Command Line – Make Program Read from Pipe First, Then from Keyboard

catcommand linepipestdin

Consider the interactive program interactive. I have to run this program fairly frequently, and each time I run it the first few commands are the same. Obviously, having to type those commands over and over again is a pain. I have collected those command (separated by newlines) in the file cmd. Now I can do cat cmd | interactive to run the commands. The problem is that once cmd has been fully read, interactive recieves EOF and exits.

What I wish to do is first have interactive read from the pipe (obviously interactive < cmd is also acceptable) and when EOF is received, start reading from the keyboard instead.

Best Answer

Just ask cat to concatenate that file with the stdin:

cat cmd - | interactive
Related Question