How do I execute a bash script in Terminal?


Question

I have a bash script like:

#!/bin/bash

echo Hello world!

How do I execute this in Terminal?

1
83
3/9/2018 6:38:45 AM

Accepted Answer

$prompt: /path/to/script and hit enter. Note you need to make sure the script has execute permissions.

38
4/4/2016 5:09:13 PM

Yet another way to execute it (this time without setting execute permissions):

bash /path/to/scriptname

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon