![]() |
|
How to Run Bash Script - Printable Version +- My Board (https://ellohost.com/forum) +-- Forum: Tutoriel EN (https://ellohost.com/forum/forumdisplay.php?fid=8) +--- Forum: Others (https://ellohost.com/forum/forumdisplay.php?fid=20) +--- Thread: How to Run Bash Script (/showthread.php?tid=134) |
How to Run Bash Script - aaron - 08-12-2023 How to Run Bash ScriptNow that we have written a bash script, let’s learn how to run it from the terminal. There are three methods to Using the Bash CommandThe first method is by using the bash command from the appropriate directory. For example, you may have a
Then, execute the following bash command to run the bash script:
You should see the output like this: ![]() If you try to run the script without the bash command, you’ll receive a command not found error ![]() Using the ./ CommandYou can run a bash script without the bash command. However, you have to set the file to have the execute
This command modifies the file permissions so that everyone can execute the file. Once you’ve done that, execute
If you don’t set the permission correctly, the terminal will print a Permission denied error message: ![]() Like the bash command, you’ll also get a command not found error if you don’t use Run the Script From a Different DirectoryAnother alternative is to run the script from a different directory. After you create the bash script, use the
|