Wednesday, 19 November 2014

OSA: Lower case to upper case conversion and vice-versa

while(true)
do

echo " MENU
______________________________________________________________________________
1)Create a file and write into it
2)Convert Lower to Upper case
3)Convert Upper to Lower case
4)open file
5)Exit"

read choice
case $choice in

1) echo " Create and Write
------------------------------------------------------------------------------
Enter the name of file to be created ->"
read filename
if [ -f $filename ];
then
echo "filename $filename already exists,please try another filename"
else
touch $filename
chmod 777 $filename
# echo "Enter the data to be written into the file ->"
# read data
# cat>$filename
fi
;;

2) echo " Convert from Lower to Upper
------------------------------------------------------------------------------
Loading and translating Existing file :- $filename "
tr '[a-z]' '[A-Z]' <$filename
;;

3) echo " Convert from Upper to Lower
------------------------------------------------------------------------------
Loading and translating Existing file :- $filename "
tr '[A-Z]' '[a-z]' <$filename
;;

4) more $filename
;;

5) echo "Program will be terminated...."
exit 0
;;

esac
done

#tnx for using code from http://www.parazhar.blogspot.in

No comments:

Post a Comment