Wo ist der Fehler?

B

^BLooDY^

Mitglied
Das Script gibt immer eine FM aus.
Und ich weiß nicht wieso :=(
Kann mir wer sagen wieso?

---------Ausgabe------------

web19@srv01:~/html/scripts/test$ sh test.sh
test.sh: 01-02-2005: command not found false

-----------Script----------------

#!/bin/bash
datum_akt="`(date +%d-%m-%Y)`"
datum_remove="`date --date='20 days ago' +%d-%m-%Y`"

if ("$datum_akt" == "$datum_remove") then
echo "true"
else
echo "false"
fi
 
Code:
#!/bin/bash

datum_akt=`date +%d-%m-%Y`
datum_remove=`date --date="20 days ago" +%d-%m-%Y`

if [ "$datum_akt" == "$datum_remove" ] ; then
        echo "true"
else
        echo "false"
fi
 
Danke,

hast du evtl ein gutes Howto?
wo man so etwas drin findet?
alles was ich zum IF gefunden habe, ist ohne dieses ";"
 
Die Syntax von if ist folgende:
Code:
if
    Befehl
then
    Befehl
    ....
else
    Befehl
    ....
fi

Dein erster Befehl ist test oder seine Abkuerzung [ ... ]
Wenn IF und Then in einer Zeile stehen ist das Semikolon noetig.


http://www.linuxfibel.de/bashprog.htm
man bash

if list; then list; [ elif list; then list; ] ... [ else list; ] fi
The if list is executed. If its exit status is zero, the then list is executed. Otherwise, each elif list is executed in turn, and if its exit status is zero, the corresponding then list is executed and the command completes. Otherwise, the else list is executed, if present. The exit status is the exit status of the last command executed, or zero if no condition tested true.
 

Ähnliche Themen

Switche abfragen über Script

NAS-Drive Mount in Bash-Script über crontab

Verschlüsseltes Backup-Script mit rsync

Script kopieren

Rückgabe eines Befehls

Zurück
Oben