Reading from a text file and executing contents in terminal
14,458
Solution 1
it can be done. Just cd to the directory of the file in the terminal and type chmod +x commands.txt
, and then ./commands.txt
runs commands in the file
No, it need not be .txt
, extension doesn't matter
Solution 2
You can also put one command per line in the text file (e.g. my_commands.txt
), and then run them all as:
source my_commands.txt
Author by
TerNovi
I have used linux distributions to program in c++ through the command line. I recently have started using 12.04 as my main operating system and I am learning a lot.
Updated on September 18, 2022Comments
-
TerNovi over 1 year
Lets say I wanted to create a .txt file that had some commands in it. Then from .txt file the contents are extracted to the terminal. Is this even possible and does it have to be a .txt file? oh and I am running 12.04
-
Admin about 6 yearsnot on all sytems:
./myfile: command not found