mardi 21 juillet 2020

Comparing two variables in IF condition inside While loop in bash script

i am trying to execute a IF condition inside a while loop, But the IF condition isn't working as variables aren't expanding! kindly guide me through the proper way to compare two variables in IF condition Note - if you can see the error log - DATE was expanding thou! problem with mdate

DATE=`date +"%Y-%m-%d"`
cat path/temp_b | while read file

 
do
    
    echo 'phase2'
    mtime=$(stat -c '%y' $Src_Dir/$file)
    echo $mtime
    mdate= echo $mtime | cut -d ' ' -f1
    echo $mdate
    echo $DATE
     if ["$mdate"=="$DATE"]; then
        "$file" > path/tempc
     else
        echo 'hi'
 
     fi
done

**Error log -

phase2

2020-05-07 05:22:28.000000000 -0400

2020-05-07

2020-07-21

./test1.ksh: line 37: [==2020-07-21]: command not found

hi**

Aucun commentaire:

Enregistrer un commentaire