What is Bash Script in Linux
For example:
For example, to store “John” inside the variable “name”:
To access the value stored inside the “name” variable, simply add a “$” symbol in front:
Here, the value stored inside the “name” variable gets plugged into the echo statement which then prints the final output as:
The echo command is a simple yet useful command which is used to print values as output. The syntax to print using the echo command is:
Sometimes you may need to take situational decisions depending on different conditions. In bash, you can take different decisions withif,thenandelsecommands with the following syntax:
For example, to check if two values in a variable are equal or not:
Here’s a breakdown of the above syntax:
For example, to print all integers between 1 and 5:
In general, while loops are used when you don’t know exactly how many times you need to repeat a particular set of statements. They will continue to repeat the statements until a particular set condition is met. The syntax to use the while loop is –
In the above syntax:
For example, to print all integers between 1 and 5:
OR
Seems complicated? Let’s break it down into parts:
For example, to make the file test.sh as executable:
To run the test.sh file:
Bringing the latest in technology, gaming, and entertainment is our superhero team of staff writers. They have a keen eye for latest stories, happenings, and even memes for tech enthusiasts.