Published on Oct. 14, 2021
Bash scripting is an extremely powerful and useful part of system administration and development. For the beginner, this might seem an extremely scary part, but once you understand the logic you can actually do a lot of things using this.
We have already done a lot of discussion on the introduction of shell script, you can find that here - What is Shell Scripting?
In this article, we are going to learn how to create a simple bash script file and add some basic logic there.
In order to create a simple bash script file follow the following steps:
As I am working on RedHat 8, so here are my steps:
Opening vi(text editor)
vi basic.sh
File code -
#!/usr/bin/bash //path of bash interpreter
echo "Hello BrighterBees"
In order to execute the bash script we have the following ways:
bash basic.sh
To run your script file as executable firstly you have to make your file executable. To make the file executable follow the command:
chmod +x basic.sh
Once the file become executable use the below command to execute that
./basic.sh
Here is how you can get started with Bash scripting. Try to run different-different commands in your script.
To learn more about bash scripting bookmark this page so that you don't miss the future updates.
Connect with the author on Twitter.
···