Shell keywords, expression, echo etc

 

 

01. SHELL KEYWORDS :

echo, read, if fi, else, case, esac, for , while , do , done, until , set, unset, readonly, shift, export, break, continue, exit, return, trap , wait, eval ,exec, ulimit , umask.

 

02. EXPRESSION Command :

To perform all arithmeticoperations .

Syntax :

Var = `expr$value1 + $value2`

Arithmetic The Bourne shell does not support arithmetic. UNIX/Linux commands must be used to perform calculations.

EXAMPLE

n=`expr 5 + 5`

echo $n

Operators The Bourne shell uses the built-in test command operators to test numbers and strings.

EXAMPLE

Equality:

= string

!= string

-eqnumber

-ne number

Logical:

-a and

-o or

! not

Logical:

AND &&

OR ||

Relational:

-gtgreater than

-gegreater than, equal to

-ltless than

-le less than, equal to

Arithmetic :

              +, -, \*, /, %

Arguments (positional parameters) Arguments can be passed to a script from the command line. Positional parameters are used to receive their values from within the script.

EXAMPLE

At the command line:

             $ scriptname arg1 arg2 arg3 ...

             In a script:

echo $1 $2 $3

Positional parameters echo $*

All the positional parameters echo $#

The number of positional parameters

03.READ Statement :

To get the input from the user.

Syntax :

read x y

            (no need of commas between variables)

04. ECHO Statement :

Similar to the output statement. To print output to the screen, the echo command is used.Wildcards must be escaped with either a backslash or matching quotes.

Syntax :

Echo “String” (or) echo $ b(for variable).

EXAMPLE

echo "What is your name?"

Reading user input The read command takes a line of input from the user and assigns it to a variable(s) on the right-hand side. The read command can accept multiple variable names. Each variable will be assigned a word.

EXAMPLE

echo "What is your name?"

 read name read name1 name2 ...

Comments

Popular posts from this blog

what is Machenical Engineering

PHOTO ( CHINESE LADKA)

Arithmatic operations, factorial of a number, while loop, prime number, etc