Example Script 1

[prabhucloudxlab@cxln4 ~]$ cat>ex1.sh 

#! /bin/bash

#pass the message in echo function

echo "my name is HARITARAKAPRABHU"
sleep 2
echo "i'm doing hadoop testing job"
sleep 2
echo "                                          "
echo "----------------------------------------------------------------------------------------------------"


#pass the variable manually

height="180 cm"
weight="80 KG"

echo "my height is $height"
sleep 2
echo "my height , weight is : $height,$weight "
sleep 2
echo "                                          "
echo "----------------------------------------------------------------------------------------------------"


#pass the variable randomly

echo "what is your country "
read country
echo "what is your  place_of_birth "
read place_of_birth

echo "my country  is $country"
sleep 2
echo "my place_of_birth is $place_of_birth"
sleep 2
echo "                                          "
echo "----------------------------------------------------------------------------------------------------"


#pass the variable randomly with arguments or parameters($ position)

place=$1
pincode=$2
dist=$3

echo "My place is : $place"
sleep 2
echo "$place is belongs to the pincode:$pincode"
sleep 2
echo "I'm from $place and district is : $dist"
sleep 2
echo "                                          "
echo "----------------------------------------------------------------------------------------------------"


# passing the commands in Variables 

user=$(whoami)
whereami=$(pwd)
date=$(date)
whether=$(curl wttr.in/$pincode)


echo "I'm $user"
sleep 2
echo "my directory is: $whereami"
sleep 2
echo "Today date is: $date"
sleep 3
echo "whether Report: $whether"


OUTPUT:

[prabhucloudxlab@cxln4 ~]$ ./ex1.sh ANDHRA 534211 WESTGODHAVARI
my name is HARITARAKAPRABHU
i'm doing hadoop testing job

----------------------------------------------------------------------------------------------------
my height is 180 cm
my height , weight is : 180 cm,80 KG

----------------------------------------------------------------------------------------------------
what is your country
INDIA
what is your  place_of_birth
TANUKU
my country  is INDIA
my place_of_birth is TANUKU

----------------------------------------------------------------------------------------------------
My place is : ANDHRA
ANDHRA is belongs to the pincode:534211
I'm from ANDHRA and district is : WESTGODHAVARI

----------------------------------------------------------------------------------------------------

I'm prabhucloudxlab
my directory is: /home/prabhucloudxlab
Today date is: Fri Jul  8 07:01:12 UTC 2022
whether Report: Weather report: 534211

                Overcast
       .--.     +80(86) °F
    .-(    ).   → 17 mph
   (___.__)__)  6 mi
                0.0 in
                                                       ┌─────────────┐
┌──────────────────────────────┬───────────────────────┤  Fri 08 Jul ├───────────────────────┬──────────────────────────────┐
│            Morning           │             Noon      └──────┬──────┘     Evening           │             Night            │
├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤
│               Overcast       │      .-.      Light rain     │      .-.      Light drizzle  │               Overcast       │
│      .--.     +78(84) °F     │     (   ).    +80(87) °F     │     (   ).    +77(82) °F     │      .--.     +77(82) °F     │
│   .-(    ).   → 14-20 mph    │    (___(__)   → 18-22 mph    │    (___(__)   → 12-19 mph    │   .-(    ).   → 11-18 mph    │
│  (___.__)__)  6 mi           │     ‘ ‘ ‘ ‘   5 mi           │     ‘ ‘ ‘ ‘   1 mi           │  (___.__)__)  6 mi           │
│               0.0 in | 0%    │    ‘ ‘ ‘ ‘    0.0 in | 70%   │    ‘ ‘ ‘ ‘    0.0 in | 84%   │               0.0 in | 0%    │
└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘