Error:give a space b/w else if and followed by then and at the end fi.
I rearranged the code listed below,pls go through it and let me know.i executed script successfully and all the files convert into
capital letter or vice verse ( change into tr A-Z a-z)
this code valid for all the files must be in small letter then this script convert into capital letter
==========
ENJOYS
=============
#Date: xx-xx-xxxx
#Purpose : illustrae using tr in a script to convert upper to lower filenames
echo $0;
# basename get rid of anything except from file/directory name.
myscriptname=`basename $0`;
#exit;
for i in `ls -A`
#DO NOT ENTER ANYTHING HERE!! ELSE SYNTAX ERROR
do
if [ $i = $myscriptname ]
then
echo "sorry can't rename myself"
else if [ $i != $myscriptname ]
then
newname=`echo $i | tr a-z A-Z`
mv $i $newname
fi
fi
done
~
Quote:
Originally Posted by taiwf
I am learning the shell script but i keep getting error message. Can somone kindly point me where i went wrong? (is bash not supporting elseif?)
---------------------------------------------------
#!/bin/bash
#Author: dav
#Date: xx-xx-xxxx
#Purpose : illustrae using tr in a script to convert upper to lower filenames
echo $0;
# basename get rid of anything except from file/directory name.
myscriptname=`basename $0`;
#exit;
for i in `ls -A`
#DO NOT ENTER ANYTHING HERE!! ELSE SYNTAX ERROR
do
if [ $i = $myscriptname ]
then
echo "sorry can't rename myself"
elseif [ $i != $myscriptname ]
newname=`echo $i | tr A-Z a-z`
mv $i $newname
fi
done
----------------------------------------------------
#./tr1.sh
#sorry can't rename myself
#./tr1.sh: line 19: elsif: command not found
#mv: `tr1.sh' and `tr1.sh' are the same file
ps: i tried else if , elseif but none of them remove the error message.
Thanks in advance
|