I have a bash script like:
#!/bin/bash echo Hello world!
How do I execute this in Terminal?
I have a bash script like:
#!/bin/bash echo Hello world!
How do I execute this in Terminal?
$prompt: /path/to/script
and hit enter. Note you need to make sure the script has execute permissions.
Yet another way to execute it (this time without setting execute permissions):
bash /path/to/scriptname
You could do:sh scriptname.sh
cd to the directory that contains the script, or put it in a bin folder that is in your $PATH
then type
./scriptname.sh
if in the same directory or
scriptname.sh
if it's in the bin folder.
Change your directory to where script is located by using cd command
Then type
bash program-name.sh
Firstly you have to make it executable using: chmod +x filename . At the filename you should write the name of you file as it is, for example: helloworld.sh After you made it executable then you can run it using /.filename Hope it helped:)