My purpose is to quickly retrieve saved bash commands and edit the commands in the bash command buffer (e.g. changing arguments, to experiment with long complex commands). When I press Enter, the command will execute, and pressing Arrow Up, will get me the command again for further editing.
For example, I have a text file called
textfile, with the following contents:
I want to get that file content into the command buffer so that I get
user@ubuntu:~$ ls -l
Because now I can modify and re-execute it.
If I add the execute bit to
textfile, I can execute it, but pressing Arrow Up, sets the
./textfile command into the command buffer, not the contents.
Similarly if I enter
$(<textfile) it also executes the command, but pressing Arrow Up, just gives me the
$(<textfile) command, not its contents
The only solution I can think of is to do
cat textfile and then copy / paste the contents into the terminal window. Well, I could also edit the file, save it, and execute it, but that's a hassle to do each time. So, is there a trick to get the contents of a file into the command buffer without typing or pasting?