Scripting basics

i have 9 aruments in total

$1 $2 $3 $4 $5 $6 $7 $8 $9

after 10 th argument we use ${10} ${11} ...

$1 -- FIrst Argument

$2 -- Second Argument

$3 -- Third Argument

$0 -- Script Name

$# -- Total Number of Arguments

$* -- All Arguments as a Single String

$@ -- All Arguments as Separate Strings

$$ -- Process ID of the Script

$? -- Exit Status of the Last Command

0 -- success

non zero -- failure

# Comparison Operators in Bash

-eq -- equals

-ne -- not equals

-gt -- greater than

-lt -- less than

-ge -- greater than or equals

-le -- less than or equals

# Logical Operators in Bash

-! -- NOT

-&& -- AND

-|| -- OR

# if statement

if [ condition ];

then

# code to be executed if condition is true

else

# code to be executed if condition is false

fi

Last updated