I have a script that reads a line from a file into variable foo. The line is in fact a long command that I often use as a template. I am trying to edit and re-use this long command. How can I place $foo on the command line ready to edit? I do not want to copy and paste the line, nor do I want to use any new apps that need installing such as xdotool. I only want to use the basic Linux commands if possible.
The method with partial success is to append the line to the .bash_history file and then recall it in the usual way. But to do this I need to close the terminal and re-open it (so that the latest copy of the history file is loaded to RAM).