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.

Linux Mastery: Mastering the Linux Command Line | Udemy

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

Output :-

Even numbers from 1 to 10
2
4
6
8
10

To be continued... Click Here

Comments

Post a Comment

Popular posts from this blog

Some tips about the right way to charge your phone

Software Basics

Some unique and weird things about Japan