LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   syntax error near unexpected token `else' (https://www.linuxquestions.org/questions/programming-9/syntax-error-near-unexpected-token-%60else-482347/)

josedias 09-11-2006 04:02 AM

syntax error near unexpected token `else'
 
Hi i think this is a stupip question too. But I hope than any one can help me to solve it .
./rootb.txt: line 12: syntax error near unexpected token `else
./rootb.txt: line 12: `else


#! /bin/bash
mkdir /backup_sistem/sistem

A="`date | cut -d" " -f3`"
if [ "$A" == " " ] ;
than
date | cut -d" " -f1,2,4,7 > /backup_sistem/.data
B="`cut -c1,2,3,5,6,7,9,11,12,13,14 /backup_sistem/.data`"
cp -rf /home/* /backup_sistem/sistem/
cd /backup_sistem/
tar -cvf "`echo $B.tar`" /backup_sistem/sistem/* &> /dev/null
else
date | cut -d" " -f1,2,3,6 > /backup_sistem/.data
B="`cut -c1,2,3,5,6,7,9,10,12,13,14,15 /backup_sistem/.data`"
cp -rf /home/* /backup_sistem/sistem/
cd /backup_sistem/
tar -cvf "`echo $B.tar`" /backup_sistem/sistem/* &> /dev/null
fi
rm -rf /backup_sistem/sistem
exit




best regards
jose

zulfilee 09-11-2006 04:07 AM

Its 'then' not 'than' after 'if' .

Also when you face a problem in script run it with a '-x' argument.You will come close to the problem.

Ex:

sh -x one.sh

josedias 09-11-2006 06:30 PM

Thankz very much zulfilee.
with ur help I had solve the problem.

regards

jose

Tinkster 09-11-2006 07:09 PM

And if you tried to use actual English more (like in spelling and proper grammar)
you may run into less problems coding, too.


;)



Cheers,
Tink


All times are GMT -5. The time now is 03:39 AM.