Make program first read from pipe, then from keyboard

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.

Asked By: Viktor Dahl

||

Just ask cat to concatenate that file with the stdin:

cat cmd - | interactive
Answered By: manatwork
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.