Reading from a text file and executing contents in terminal
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
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