natv
Programmer
- Jun 5, 2007
- 3
Hey guys,
I'm learning bash scripting through self study and in a video training the instructor is demonstrating a script that converts lowercase file names to uppercase to help learn some basics.
I've copied the script from the screen, and looked over it 50 times and I'm almost certain that I've copied it correctly, but I get an error when I run it (and it works for the instructor)
So I must be doing something wrong. This is the simple script:
When I run it, I get:
# ./tr1.sh
./tr1.sh: line 14: syntax error near unexpected token `fi'
./tr1.sh: line 14: ` fi'
line 14 just has "fi".
I also tried using spaces instead of tabs to intent it, but that didn't make any difference.
Any idea what I'm missing? If it helps I'm using CentOS 4.4 and the bash version is bash-3.0-19.3
Thanks
Nat
I'm learning bash scripting through self study and in a video training the instructor is demonstrating a script that converts lowercase file names to uppercase to help learn some basics.
I've copied the script from the screen, and looked over it 50 times and I'm almost certain that I've copied it correctly, but I get an error when I run it (and it works for the instructor)
So I must be doing something wrong. This is the simple script:
Code:
#!/bin/bash
#Purpose: Illustrate using tr in a script to convert upper to lower file names
myscriptname=`basename $0` ;
for i in `ls -A`
do
if [ $i = $myscriptname ]
then
echo "Sorry, can't rename myself!"
elif [ $i != $myscriptname ]
newname=`echo $i | tr a-z A-Z`
mv $i $newname
fi
done
#END
When I run it, I get:
# ./tr1.sh
./tr1.sh: line 14: syntax error near unexpected token `fi'
./tr1.sh: line 14: ` fi'
line 14 just has "fi".
I also tried using spaces instead of tabs to intent it, but that didn't make any difference.
Any idea what I'm missing? If it helps I'm using CentOS 4.4 and the bash version is bash-3.0-19.3
Thanks
Nat