You can do this with a shell script that contains these commands. Typically, the extension will be .sh (so name it commands.sh instead of commands.txt ).
Then you can run it using bash commands.sh .
In addition, if the first line of your file is #!/bin/bash , and if you make it executable (for example, via chmod 755 commands.sh ), you can execute this file directly: ./commands.sh .
Other lines starting with # (or anything after # in the line) will provide comments if you need to.
Here are some guides:
There are other shells besides bash, but bash is used by default for OSX (same as /bin/sh ): this is what you are already using in the terminal. This is also the default for the number of Linux distributions.
Bruno source share