Welcome to Our Website

Write a shell program to convert all lowercase letter in a file to uppercase letter

QUE: Write a shell program to convert all lowercase letter in a file to uppercase
letter.

ANS –

clear
echo “Menu”
echo “1. Lower Case to Upper Case”
echo “2. Upper Case to lower Case”
echo “3. Quit”
echo “Enter ur Choice \c”
read Choice
case”$Choice”in
1] echo “Enter File: \c”
read f1
if [ -f $f1 ]
then
echo “Converting Lower Case to Upper Case ”
tr ‘[a-z]”[A-Z]’ <$f1

else
echo “$f1 does not exist”
fi
;;
2] echo “Enter the File :\c”
read f1
if [ -f $f1 ]
then
echo “Converting Upper case to Lower Case to ”
tr ‘[A-Z]”[a-z]’ <$f1

else
echo “$f1 file does not exist ”
fi
;;
3|*)
echo “Exit…….”
exit;;
esac

output:

$ cat >hello
how r u ….
how is the day….
go.
$ SH36
Menu
1. Lower to Upper
2. Upper to lower
3. Quit
Enter ur Choice 1
Enter the File :HELLO
Converting Lower case to Upper Case to
HOW R U ….
HOW IS THE DAY.
GO
$ SH36
Menu
1. Lower to Upper
2. Upper to lower
3. Quit
Enter ur Choice 1
Enter the File :HELLO
Converting Lower Case to Upper Case
XCO
ASA
GATE

Leave a Reply

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