为什么“如果”声明不起作用?

时间:2016-02-05 13:56:47

标签: bash

我似乎不明白为什么我的if语句不起作用。由于某种原因,它不起作用,我真的希望有人可以给我建议!

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=(*)
        for ((x=0; x<${#files[@]}; x++))
            do
        cd ${files[$x]}
        cd full
        rsync `ls -tp | grep -v / | head -n 2` ../../../../../backupmap/$BUDATE
        cd ../../
    done
}

function copyinc {
    cd nfs/backup/servers
    files=(*)
        for ((x=0; x<${#files[@]}; x++))
            do
        cd ${files[$x]}
        cd incremental
        rsync `ls -tp | grep -v / | head -n 4` ../../../../../backupmap/$BUDATE
        cd ../../
    done
}

function fullorinc ($BackupType){
        if [[ $BackupType=="inc" ]]; then
        copyinc
    elif [[ $BackupType=="full" ]]; then
        copyfull
    elif [[ $BackupType=="" ]]; then
        echo "Couldn't get the current date."
    fi

}
startup
getDay

1 个答案:

答案 0 :(得分:3)

class="box active"==周围的空格不是可选的。没有他们,你的病情就被理解为

[[ ... ]]