Friday 20 April 2018

Shell script to change content into upper case

#Script to change the file name and contents into upper case
echo "enter the filename"
read fname
echo "File name changed to upper case"
if [ -f $fname ]
then
  echo $fname |tr '[a-z]' '[A-Z]'
fi

echo "\nOriginal file content"

cat $fname
echo "\nFile content in upper case"
tr '[a-z]' '[A-Z]' <$fname



OUTPUT
Safi>sh trans.sh
enter the filename
file2
File name changed to upper case
FILE2

Original file content
103 Banu CIO
103 Banu CIO
103 Banu CIO
104 Shan CFO
101 Sasha MD

File content in upper case
103 BANU CIO
103 BANU CIO
103 BANU CIO
104 SHAN CFO
101 SASHA MD

No comments:

Post a Comment