lundi 21 septembre 2015

Problems with BASH variable multiplication inside if statment

I am having an issue getting BASH to update a variable in a piece of scripting that I am working on. Below is an excerpt from my script that I have having troubles with

read -p "Did you plan on running the server from a Ramdisk?(y/n)" RAMDISK
        if [[ "$RAMDISK" == [yY] ]]; then
                read -p "What is the full path to where you would like to create the ramdisk?(/var/RAMDISK)" RAMDIR
                read -p "How big did you want the ramdisk to be?(2048)" RAMSIZE
                if [[ "$RAMSIZE" -lt 1024 ]]; then
                        $NEWRAMSIZE = $((RAMSIZE*1024)) #FIXME
                        echo $NEWRAMSIZE
                fi
                RAMDISK="Enabled"
        fi

        if [[ "$RAMDISK" == [nN] ]]; then
                RAMDISK="Disabled"
        fi
        echo $NEWRAMSIZE

My problem is that no matter what I am trying, the RAMSIZE variable never gets multiplied by 1024. I am trying to make it so no matter what number you enter, it will always get changed to a size in mb instead of gb, assuming anything less than 1024 is a gb size. Earlier in the script RAMSIZE defaults to 2048 and it never seems to be changed during the if statement. Please help?

Aucun commentaire:

Enregistrer un commentaire