0

I have a program that reads user input—moves, it's a boardgame—from the user. Like so:

$ game
enter your move: 
# etcetera

The first N moves I need to repeat each time, so I put them in a text file, one line each. That works:

$ game < moves.txt

This works, but after these N moves, how do I return to input from the command line?

I realize this is probably a duplicate question, but I couldn't find it.

2
0

I actually found the answer on stackoverflow in the mean time, after some more intense Googling:

At https://stackoverflow.com/questions/1561055/switch-from-file-contents-to-stdin-in-piped-command-linux-shell:

(cat moves; cat) | game

And a very useful comment by Zack:

"For those who are interested, you can build onto the file containing commands as you go by using: (cat your_file_with_commands; tee -a your_file_with_commands) | sh your_script which will append each command to the file in addition to passing it to the script via the pipe."

Not the answer you're looking for? Browse other questions tagged or ask your own question.