Skip to main content
  4. Calculator Shell Script echo "Enter two numbers:" read a b echo "1.Add 2.Subtract 3.Multiply 4.Divide" read ch case $ch in 1 ) echo "Sum = $((a+b)) " ;; 2 ) echo "Difference = $((a-b)) " ;; 3 ) echo "Product = $((a*b)) " ;; 4 ) echo "Division = $((a/b)) " ;; *) echo "Invalid choice" ;; esac ✅ 5. Student Marksheet Script echo "Enter marks of 3 subjects:" read m1 m2 m3 total = $((m1+m2+m3)) percentage = $((total/3)) echo "Total = $total " echo "Percentage = $percentage " if [ $percentage -ge 60 ] then echo "Class: First" elif [ $percentage -ge 50 ] then echo "Class: Second" else echo "Class: Pass" fi ✅ 6. Palindrome Number Script echo "Enter number:" read num rev = 0 temp = $num while [ $num -gt 0 ] do rem = $((num%10)) rev = $((rev*10+rem)) num = $((num/10)) done if [ $temp -eq $rev ] then ec...

 

4. Calculator Shell Script

echo "Enter two numbers:"
read a b

echo "1.Add 2.Subtract 3.Multiply 4.Divide"
read ch

case $ch in
1) echo "Sum = $((a+b))";;
2) echo "Difference = $((a-b))";;
3) echo "Product = $((a*b))";;
4) echo "Division = $((a/b))";;
*) echo "Invalid choice";;
esac

5. Student Marksheet Script

echo "Enter marks of 3 subjects:"
read m1 m2 m3

total=$((m1+m2+m3))
percentage=$((total/3))

echo "Total = $total"
echo "Percentage = $percentage"

if [ $percentage -ge 60 ]
then
echo "Class: First"
elif [ $percentage -ge 50 ]
then
echo "Class: Second"
else
echo "Class: Pass"
fi

6. Palindrome Number Script

echo "Enter number:"
read num

rev=0
temp=$num

while [ $num -gt 0 ]
do
rem=$((num%10))
rev=$((rev*10+rem))
num=$((num/10))
done

if [ $temp -eq $rev ]
then
echo "Palindrome"
else
echo "Not Palindrome"
fi

7. Factorial Script

echo "Enter number:"
read n

fact=1

for ((i=1;i<=n;i++))
do
fact=$((fact*i))
done

echo "Factorial = $fact"

8. Fibonacci Series Script

echo "Enter n:"
read n

a=0
b=1

echo "Fibonacci series:"
for ((i=1;i<=n;i++))
do
echo -n "$b "
fn=$((a+b))
a=$b
b=$fn
done

9. Menu Driven Shell Script

echo "1. Calendar"
echo "2. Date and Time"
echo "3. Logged in users"
echo "4. Display name at position"
echo "5. Terminal number"

read ch

case $ch in
1) cal ;;
2) date ;;
3) who ;;
4) tput cup 10 20
echo "YourName" ;;
5) tty ;;
*) echo "Invalid choice" ;;
esac

10. Date, Time & Welcome Script

hour=$(date +%I)
ampm=$(date +%p)

echo "Current Time: $(date +"%I:%M:%S %p")"
echo "Date: $(date)"

if [ $hour -lt 12 ]
then
echo "Good Morning"
elif [ $hour -lt 18 ]
then
echo "Good Afternoon"
else
echo "Good Evening"
fi

Comments

Popular posts from this blog

How to Get Insurance: A Step-by-Step Guide for Beginners

How to Get Insurance: A Step-by-Step Guide for Beginners Whether you’re buying your first car, starting a business, or protecting your family’s future, insurance is an essential part of life. Yet, for many people, the process of getting insurance feels overwhelming. With so many options, companies, and types of coverage available, it’s easy to get lost. Don’t worry — you’re not alone. In this guide, we’ll break down how to get insurance step-by-step, so you can confidently choose the right policy for your needs. Why Insurance Matters Before we dive into the process, let’s quickly understand why insurance is important. Insurance acts as a financial safety net. It protects you against unexpected events like accidents, illnesses, theft, or disasters. Without insurance, you might face huge expenses that could devastate your finances. From health and auto insurance to life and home insurance, having the right coverage means peace of mind — knowing that if the unexpected happens...