Lab 11
Lab 11
Lab 11
#! /bin/bash
#! /bin/bash
# My first script
#
clear
a) System variables
Created and maintained by Linux itself. This type of variable defined in CAPITAL
LETTERS.
Created and maintained by user. This type of variable defined in lower LETTERS.
Example:
$ echo
$USERNAME
$ echo
$HOME
NOTE: Here 'value' is assigned to given 'variablename' and Value must be on right side =
sign. For Example
$ no=10
$ 10=no
# Error To define variable called “vech” having value Bus
$ vech=Bus
To define variable called n having value 20
$ n=20
Note: Don't put spaces on either side of the equal sig when assigning value to variable.
Variables are case-sensitive, just like filename in Linux.
$ echo
$ no # will print 10
$ echo
$ vech # will print Bus
$ echo
$n # will print 20
You can define NULL variable as follows (NULL variable is variable which has no value at
the time of definition).
$vech=
$vech=""
Try to print it's value $ echo $vech, Here nothing will be shown because variable has no
value i.e. NULL variable.
Example:
$ echo "Today is date"
Can't print message with today's date.
$ echo "Today is `date`".
Now it will print today's date as, Today is Tue Jan ...., Note that the `date` statement uses
back quote.
$ vigetin
#!/bin/bash
#Script to read your Name from keyboard
#
Echo “Enter Your First Name:”
read name
echo “Hello $name”
LAB TASK
1.Take two inputs from user and then perform arithmetic operations
2.Use system variables and user defined variables to show how that value can be accessed.
3.Show results of double , single and back quote.