Tuesday, 21 April 2015

Write a shell script that accepts one or more file names as arguments, and converts them all to upper case if they exist

for var in $@
check=`ls -al $var 2>/tmp/err | grep -w $var | cut -d " " -f 9`
if [ "$check" == "$var" ];then
upper_case=`echo $var | tr '[a-z]' '[A-Z]'`
echo "file before uppercase"
echo $var
echo "***file after uppercase***"
mv $var $upper_case
echo $var
echo "$var file doesnt exists"

No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2016