I have several bunch of linux
commands contained in a text file, separated by \n\n
, and I would like to automatically paste each in given screen processes. For the sake of clarity, let's say my command.txt
simply contains :
#first bunch of commands:
executable_script1.sh
mv executable_script1 directory1
#second bunch of commands:
executable_script2.sh
mv executable_script2 directory2
So the first bunch of commands would run executable_script1.sh
, after what it will move executable_script1
. In this example, my screen contains 3 processes:
0$ htop
1$ bash
2$ bash
The name of the processes is irrelevant, the only important information is that I would like commands N
in screen process N$
, as 0$
is always a htop
.
As for now, I have been copying/pasting manually each bunch of commands in the corresponding screen processes, which worked obviously, but now I will be dealing with more than 40 bunch of commands and as many screen processes. So, how could I paste the commands N
to the N$
screen terminal automatically? I think a bash
/shell
script could do the trick, but I am not fluent enough with it. I currently use a python2
script to generate my command.txt
file, so mind that I could create one txt
file by bunch of commands pretty easily if needed.
Could you help me with this? Please feel free to ask for any missing information.
PS: I also asked this question on Unix Stackexchange, but this forum seems far less populated... If we find an answer here, I will invite the answerer to paste it under my Unix Stackexchange question as well, as this could help others!