bash - Why is 'if' statement not working? -
i don't seem understand why if statement isn't working. reason doesn't work , hope can give me advice!
function startup { #budate bevat het jaartal,maand en dag van nu. budate=`date +%y%m%d` #maakt directory aan in backup map met datum als naam mkdir backupmap/$budate } function getday { dow=$(date +%u) backuptype="" case $dow in '1' ) #maandag backuptype="inc" ;; '2' ) #dinsdag backuptype="inc" ;; '3' ) #woensdag backuptype="inc" ;; '4' ) #donderdag backuptype="inc" ;; '5' ) #vrijdag backuptype="full" echo "got date" ;; '6' ) #zaterdag backuptype="inc" ;; '7' ) #zondag backuptype="full" ;; esac } function copyfull { cd nfs/backup/servers files=(*) ((x=0; x<${#files[@]}; x++)) cd ${files[$x]} cd full rsync `ls -tp | grep -v / | head -n 2` ../../../../../backupmap/$budate cd ../../ done } function copyinc { cd nfs/backup/servers files=(*) ((x=0; x<${#files[@]}; x++)) cd ${files[$x]} cd incremental rsync `ls -tp | grep -v / | head -n 4` ../../../../../backupmap/$budate cd ../../ done } function fullorinc ($backuptype){ if [[ $backuptype=="inc" ]]; copyinc elif [[ $backuptype=="full" ]]; copyfull elif [[ $backuptype=="" ]]; echo "couldn't current date." fi } startup getday
the spaces around ==
in [[ ... ]]
not optional. without them, condition understood as
[[ -n "$backuptype==" ]]
Comments
Post a Comment