00_B_Linux_Shell_Scripts
00_B_Linux_Shell_Scripts
1. Shell scripts serve as a powerful tool for automating tasks and managing system
configurations. To execute a Bash shell script, enter the bash command followed by
the shell script name:
bash ./example_script.sh
Assuming that the users default shell is Bash (as seen in the /etc/passwd file), the Bash
command is optional:
./example_script.sh
Example 1
Before executing a bash script, use the chmod command to add the user execute
permission.
If writing and saving the shell script using Windows, run the following command in
your terminal to replace the CR LF (\r\n) characters with the LF (\n) character.
Execute the Bash shell script using the bash command.
Execute the Bash shell script without using the bash command.
Example 2
Example 3
References
https://ioflood.com/blog/run-bash-script/
https://linuxhandbook.com/bash-automation/