Linux Bash Scripting
Linux Bash Scripting
Writing Bash scripts is a powerful way to interact with our Linux system. Bash scripts can be used any time you have a repeated set of commands that you use on a regular basis.

bash
It is a interpreter that executes commands read from a file or standard input.
echo
This command is used to display line of text/string that are passed as an argument.
if else statement
If-else is the decision making statements in bash scripting where execution of a block of statement is decided based on the result of if condition. If it evaluates a condition to true, then if block code is executed, on the false condition, the else block code is executed, which is optional.
Loops - Bash Scripting
1. for loop - It is a bash programming language statement which allows code to be repeatedly executed.
2. while loop -
3. until loop -
Example :-
Print all even number from 1 to 10.
echo “Even numbers from 1 to 10”
for i in {1..10};
do
i = 2
while [ $i -le 10]
do
echo “$i”
i=$((i+2))
done
for i in {1..10};
do
i = 2
while [ $i -le 10]
do
echo “$i”
i=$((i+2))
done
Output :-
It's great and useful
ReplyDelete