Home Linux Write a shell script to display calendar in the following manner.

Write a shell script to display calendar in the following manner.

1 min read
0
0
60

Write a shell script to display calendar in the following manner.

  • Display the calendar of months m1 and m2 by ‘CAL m1 ,m2 ‘ command line.
  • Display the calendar of the months from m1 to m2 by ‘CAL m1-m2’ command line.

if [ $# -eq 1 ]

then

y="-"

z=","

L=`echo $1 | wc -c`

i=1

c=0

while [ $i -le $L ]

do

x=`echo $1 | cut -c $i`

if [ $x -eq $y ]

then

c=1

break

elif [ $x -eq $z ]

then

c=2

break

first=`expr $first+1`

fi

i=`expr $i+1`

done

second=`echo $1 | cut -d "," -f 2`

cal $first 07

if [ $c -eq 1 ]

then

first=`echo $1 | cut -d "-" -f 1`

second=`echo $1 | cut -d "-" -f 2`

while [ $first -le $second ]

do

cal $first 07

done

elif [ $c -eq 2 ]

then

first=`echo $1 | cut -d "," -f 1`

cal $second 07

else

echo "Argument not enter correctly..."

fi

else

echo "Invalid Argument.... Usage : 34 m1,m2 or 34 m1-m2"

fi

Load More Related Articles
Load More By coder coder
Load More In Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

Prime Or Not Prime vb.net Program.

Prime Or Not Prime . …