How do I run a shell script without using “sh” or “bash” commands?

Add a “shebang” at the top of your file:

#!/bin/bash

And make your file executable (chmod +x script.sh).

Finally, modify your path to add the directory where your script is located:

export PATH=$PATH:/appropriate/directory

(typically, you want $HOME/bin for storing your own scripts)

Leave a Comment