Bash Lowercase and Uppercase
GTU OS Practical- 14 Write an awk program using function, which convert each word in a given text into capital. echo “Enter the String” a=$(awk ‘BEGIN{ getline str; print toupper(str); }’) echo $a Output
Bash Date Validator
GTU OS Practical- 13 Write a shell script to validate the entered date. (eg. Date format is : dd-mm-yyyy). echo “Enter Valid Date” read date echo “You have entered $date” date -d $date if [ $? -eq 0 ] then echo “Enter Date is Valid” else echo “Enter Date is Invalid” fi
Bash program to check if the Number is a Palindrome
GTU OS Practical- 10 Write a shell script to check entered string is palindrome or not. echo “Input your string without space” read vstr for i in $(seq 0 ${#vstr}) do rvstr=${vstr:$i:1}${rvstr} done echo “Input string was :” $vstr echo “After Reversng String Is :” $rvstr if [ “$vstr” = “$rvstr” ] then echo “String […]
Shell Programming Using Filters
GTU OS Practical- 11 Shell programming using filters (including grep, egrep, fgrep) echo “Main Menu” echo “Press 1 for using Grep Command” echo “Press 2 for using Egrep Command” echo “Press 3 for using Fgrep Command” read a case $a in 1) echo “For single pattern search, Enter Pattern below :” read b grep “$b” […]
Shell Script To Display All Executable Files, Directories And Zero Sized Files From Current Directory
GTU OS Practical- 9 Shell Script To Display All Executable Files, Directories And Zero Sized Files From Current Directory echo Executable files files=$(find lab_solutions -executable -type f) echo $files echo echo List of Directories dir=$(ls -d ) echo $dir echo echo List of zero sized files zero=$(find -size 0) echo $zero
Shell Script to Sort Number in Descending Order
GTU OS Practical- 8 Write a shell script to read n numbers as command arguments and sort them in descending order. read -p “Enter The Number: ” n for((i=0; i
Fibonacci Series in Bash
GTU OS Practical- 6 Write a shell script which will generate first n fibonnacci numbers like: 1, 1, 2, 3, 5, 13, … read -p “Enter the Number: ” number x=0 y=1 i=2 echo “Fibonacci Series Upto $number Number: ” echo “$x” echo “$y” while [ $i -lt $number ] do i=`expr $i + 1` […]
Shell Script To Find Prime Numbers
GTU OS Practical- 5 Write a shell script which will accept a number b and display first n prime numbers as output. read -p “Enter the NUmber: ” n echo “The prime numbers $n are: ” m=2 while [ $m -le $n ] do i=2 flag=0 while [ $i -le `expr $m / 2` ] […]
Shell Script To Find Factorial Of A Number
GTU OS Practical- 4 Write a shell script to find factorial of given number n. read -p “Enter the number : ” number fact=1 while [ $number -gt 1 ] do fact=$((fact * number)) #fact = fact * num number=$((number – 1)) #num = num – 1 done echo “Result:” $fact Output
Shell Script For Multiplication Table
GTU OS Practical- 3 Write a shell script to display multiplication table of given number echo “Enter Number to Generate Multiplication Table” read -p “Enter the number : ” number echo “***********************” i=1 while [ $i -le 10 ] do echo ” $number * $i =`expr $number * $i ` ” i=`expr $i + 1` […]