Bash Structure
Bash script starts with #! referred as the shebang followed by /bin/bash it actually tells the path of the interpreter to execute the commands in the script.
echo: echo is a built-in command in Bash, which is used to display the standard output by passing the arguments. It is the most widely used command for printing the lines of text/String to the screen.
bash script_name.sh
OR
./script_name.sh
Sample Script
Let's start to create our first hello world bash script.
#!/bin/bash
echo “Hello World!”
Save the file and we need to give executable permission for running.
chmod +x hello.sh
After we need to run our script using below command.
./hello.sh or bash hello.sh
Last updated