You are on page 1of 3

BORCELLE

2023

SA LAB
OPEN PROJECT

Team 6

ABIN PAUL
HARIKRISHNAN M R
KRISHNAPRASAD AYYAPPAN
ALEX JOBY
GAUTHAM SUMEER K S
AFWAN SHA J
AKSHAY M M
BASIL DENNY
1. Write a shell script to greet the system user by checking the
system time

#!/bin/bash

current_time=$(date +%H)

if [ $current_time -ge 0 -a $current_time -lt


12 ]; then
greeting="Good morning"
elif [ $current_time -ge 12 -a $current_time -
lt 17 ]; then
greeting="Good afternoon"
else
greeting="Good evening"
fi

echo "$greeting, $USER!"

Output

Good Morning, !
2. Write a shell script to read and print four command line arguments

#!/bin/bash

if [ $# -ne 4 ]; then
echo "Usage: $0 arg1 arg2 arg3 arg4"
exit 1
fi

arg1=$1
arg2=$2
arg3=$3
arg4=$4

echo "Argument 1: $arg1"


echo "Argument 2: $arg2"
echo "Argument 3: $arg3"
echo "Argument 4: $arg4"

Output
Argument1: Hello,
Argument2: How
Argument3: are
Argument4: you!!!

You might also like