Experimen 5
Experimen 5
1.Commandline
The command line in Linux is a text-based interface that allows users to interact
with the operating system by typing commands. It is also known as the shell,
terminal, console, or prompt. The command line is a powerful tool that can be used
to perform various tasks such as file manipulation, system administration, and
software installation .
To access the command line in Linux, we need to open a terminal window. Once
we have opened the terminal, we can start typing commands and pressing enter to
execute them . Some of the basic commands that you can use in the command line
include ls (list files), cd (change directory), mkdir (make directory), and rm
(remove files) .
Some examples are-
2.Array
In Linux, an array is a variable that can hold multiple values of the same type or
different types . It is a structured arrangement of similar data elements .Arrays are
useful when you want to store and manipulate a large number of variables. Instead
of creating multiple variables, you can store the same type of values in an array
and access them via an index number .
In shell scripting, arrays are used to group a set of variables together 2. You can
declare an array in a shell script using various approaches such as indirect
declaration, explicit declaration, or compound assignment 1.
Here are some basic examples that we can perform on arrays in Linux:
3.Conditional Statement
A conditional statement is a logical statement that describes a relationship between
two propositions, where the truth of one proposition depends on the truth of the
other . It is also known as an if-then statement because it consists of two parts: an
antecedent (if) and a consequent (then) .
The antecedent is the condition that must be met for the consequent to be
true .Alternatively known as a conditional expression, conditional flow statement,
and conditional processing , a conditional statement is a set of rules performed if a
certain condition is met. It is sometimes called an If-Then statement, because IF a
condition is met, THEN an action is performed.
For Example-
if (x > 0) {
In this example, the code inside the curly braces will only be executed if the
condition inside the parentheses (x > 0) is true.
4.Decision Making
There are two types of decision-making statements that are used within shell
scripting: if-else statement and case statement .
Example-#!/bin/bash