# echo "first arg : $1"1# echo "second arg : $2"2# echo "third arg : $3"34# echo "$* without quotes"5# ./m1.sh $*6# echo "$@ without quotes"7# ./m1.sh $@8# echo "$* with quotes"9# ./m1.sh "$*"10# echo "$@ with quotes"11# ./m1.sh "$@"00012# a=513# b=314# c=$(($a+$b))15# d=`expr $a - $b`16# e=`expr $a \* $b`17# f=`expr "scale=2 ; $a / $b" | bc`18# echo $c $d $e $f19# read two numbers and perform all arithmatic operation20# input 3 numbers through commandline argument and perform arithmatic operation21# fi9nd average of 3 numbers222324# echo "enter first number"25# read a26# echo "enter second number"27# read b28# c=`expr $a + $b`29# d=`expr $a - $b`30# e=`expr $a \* $b`31# f=`expr $a / $b`32# echo $c $d $e $f3334# echo "first argument $1"35# echo "second argument $2"36# echo "third argument $3"37# c=`expr $1 + $2 + $3`38# d=`expr $1 - $2 - $3`39# e=`expr $1 \* $2 \* $3`40# f=`expr $1 / $2 / $3`41# g=`expr $1 % $2 % $3`42# echo $c $d $e $f $g4344# echo "enter first number"45# read a46# echo "enter second number"47# read b48# echo "enter third number"49# read c50# d=`expr $a + $b + $c`51# e=`expr $d / 3`52# echo $e5354# a=555# b=356# c=`echo "scale=2; $a / $b" | bc`57# echo "$c"585960# there must be spaces between operators and expresions61#all the conditional expression should be inside square braces with spaces around them62# == -eq63# > -gt64# < -lt65# >= -ge66# <= -le67# != -ne68#check number is even or odd69#check given no. is +ve or -ve70# echo "enter 1st no. = "71# read a72# if [ $(($a % 2)) -eq 0 ]73# then74# echo "a is even"75# else76# echo 'odd'77# fi78#79# echo "enter 1st no. = "80# read a81# if [ $a gt 0 ]82# then83# echo "a is positive"84# if [ $a lt 0 ]85# echo "a is negative"86# else87# echo 'a is 0'88# fi89#find the largest of two numbers90#find the largest among 3 numbers.91#input the marks of a student in 3 subjects and calculate the division on the basis of percentage of marks.9293# echo "enter num1= "94# read a95# echo "enter num2= "96# read b97# if [ $a -gt $b ]98# then99# echo "a is greater"100# else101# echo "b is greater"102# fi103104# echo "enter 1st="105# read x106# echo "enter 2nd= "107# read b108# echo "enter 3rd= "109# read c110# if [ $x -gt $b -a $x -gt $c ]111# then112# echo "x is greater"113# elif [ $b -gt $x -a $b -gt $c ]114# then115# echo "b is greater"116# else117# echo "c is greater"118# fi119120121# echo "enter 1st="122# read x123# echo "enter 2nd= "124# read b125# echo "enter 3rd= "126# read c127# sum=`expr $x + $b + $c`128# avg=`echo "scale=0; $sum / 3 " | bc `129# if [ $avg -ge 80 ]130# then131# echo "first division"132# elif [ $avg -ge 65 -a $avg -lt 80 ]133# then134# echo "second division"135# elif [ $avg -ge 45 -a $avg -lt 65 ]136# then137# echo "third division"138# else139# echo "fail"140# fi141142143144#case $var in145#pattern1)146#;;147#pattern2)148#;;149#*)150#esac151152# echo "enter day number = "153# read a154# case $a in155# 1) echo "monday"156# ;;157# 2) echo "tuesday"158# ;;159# 3) echo "wednesday"160# ;;161# 4) echo "thursday"162# ;;163# 5) echo "friday"164# ;;165# 6)166# echo "saturday"167# ;;168# 7)169# echo "sunday"170# ;;171# *) echo "invalid"172# esac173#wap to check the given character is vowel consonant or special character using case174#wap to check even odd using case175#wap menu driven program to perform following operations-176#1. list of files177#2. todays date178#3. count number of lines and words in a file179#4.display number of command line argument passed.180181# echo "enter a character : "182# read c183# case "$c" in184# [AEIOUaeiou]) echo "vowel"185# ;;186# [BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz]) echo "c is consonant"187# ;;188# [0123456789]) echo "it is a digit"189# ;;190# *) echo "special character"191# ;;192# esac193194# echo "enter the number : "195# read a196# case $(($a % 2)) in197# 0) echo "even"198# ;;199# 1) echo "odd"200# ;;201# *) echo "invalid number"202# ;;203# esac204205206207# echo "select an option"208# echo "1. list of files"209# echo "2.todays date"210# echo "3. no of lines and no. of words"211# echo "4. no of command line inputs "212# echo "5. exit"213# echo "enter your choice : "214# read ch215# case $ch in216# 1) ls ;;217# 2) date ;;218# 3) echo "enter file name : "219# read file220# echo "no of lines : $(wc -l $file | awk '{print $1}')"221# echo "no of words : $(wc -w $file | awk '{print $1}')"222# ;;223# 4) echo "no of command line input :224# ;;225# 5) exit ;;226# *) echo "invalid choice"227# ;;228# esac229230# echo "Enter Operating System Marks:"231# read os232# echo "Enater C++ Marks:"233# read cpp234# echo "Enater Java Marks:"235# read java236# total=`expr $os + $cpp + $java`237# echo "Total Marks:"$total238# percentage=`expr $total / 3`239# echo "Percentage:" $percentage %240# if [ $percentage -ge 60 ]241# then242# echo "Class: First Class Distinction"243# elif [ $percentage -ge 50 ]244# then245# echo "Class: First class"246# elif [ $percentage -ge 40 ]247# then248# echo "Class: Second class"249# else250# echo "Class: Fail"251# fi252253#print numbers 1 to 10254# print multiplication table of a given number255# wap to check a given number is palindrome or not256#wap to compute m to the power a positive integer.257#wap to read student name roollno and marks in the same line and then258#write the line to a file student.txt it than prompts you for more entries259260# i=1261# while [ $i -le 10 ]262# do263# echo "$i"264# i=`expr $i + 1`265# done266267268# echo "enter a number"269# read n270# i=1271# while [ $i -le 10 ]272# do273# a=`expr $i \* $n`274# echo "$n * $i = $a"275# i=`expr $i + 1`276# done277278# echo "enter the number"279# read a280# b=$a281# s=0282# while [ $a -gt 0 ]283# do284# r=`expr $a % 10`285# s=`expr $s \* 10 + $r`286# a=`expr $a / 10`287# done288# if [ $b -eq $s ]289# then290# echo "palindrome"291# else292# echo "not palindrome"293# fi294295296# echo "enter a number"297# read a298# echo "enter power"299# read p300# b=1301# while [ $p -gt 0 ]302# do303# b=`expr $b \* $a`304# p=`expr $p - 1`305# done306# echo "$b"307308309310# echo "Enter student details (name, roll no, marks):"311# read input312#313# while [ "$input" != "quit" ]314# do315# echo "$input" >> student.txt316# echo "Student details added to file."317#318# echo "Enter 'quit' to exit or provide the next student details:"319# read input320# done321#322# echo "Program finished."323324# nums="10 15 17 18 20 25"325# for i in $nums326# do327# n=`expr $i % 2`328# if [ $n -eq 0 ]329# then330# echo "$i is even"331# else332# echo "$i is odd"333# fi334# done335336# search the pattern provided two cmd line argument in a file337# for i in $*338# do339# grep -w "$i" m1.sh || echo "pattern not found"340# done341342343344345# declare -a fruits=('Mango' 'Apple' 'Banana' 'Orange' 'watermelon')346# echo ${fruits[2]: 0:4}347# echo ${fruits[@]: 2:2}348# echo ${fruits[@]}349# echo ${fruits}350# echo ${fruits[2]}351# echo ${fruits[2]}352# echo ${fruits[@]}353# echo ${fruits[2]}354355356#input and print all the elements at the same line357# read -a arr358# for i in $arr359# do360# echo "$i"361# done362363364#input 10 integers in array and display max min total sum and avg of an array365#wap to sort an array in ascending order366367# total=0368# echo "Enter the length of the array"369# read size370# for ((i=0; i<$size; i++))371# do372# read arr[i]373# done374# max=${arr[0]}375# min=${arr[0]}376# for i in "${arr[@]}"377# do378# if [ $i -gt $max ]379# then380# max=$i381# fi382# if [ $i -lt $min ]383# then384# min=$i385# fi386# total=`expr $total + $i`387# done388# avg=$(echo "scale=2; $total/$size" | bc )389# echo "average is : $avg"390# echo "total is : $total"391# echo "Maximum is : $max"392# echo "Minimum is : $min"393394# temp=0395# echo "Enter the length of the array"396# read size397# for ((i=0; i<$size; i++))398# do399# read arr[i]400# done401# for ((i=0; i<$size; i++))402# do403# for ((j=i+1; j<$size; j++))404# do405# if [ ${arr[i]} -gt ${arr[j]} ]406# then407# temp=${arr[i]}408# arr[i]=${arr[j]}409# arr[j]=$temp410# fi411# done412# done413# echo "${arr[@]}"414415416417418# var="AaBbCcDdEeFfGg"419# test=`expr index "$var" d`420# echo $test421422423# string="www ist a string"424# substring="Xat"425# a=`expr index "$string" "$substring"`426# echo $a427428429filename="bash.string.txt"430echo ${filename##*.}431echo ${filename%%.*}432433