vendredi 31 mai 2019

If statement not giving the expected value

Hey all so I am trying to create a script using bash to hash each file in a folder, and check it hash value against a main file.

I already tried adding a ! within the if statement to see if that would help and I tested part of my code directly within the cygwin command line to see the direct output of the commands I am using to see if I could figure out my issue from that

Please note I do have this within a while read do loop

md5=$(md5sum "$p" | cut -c -32)

if [ $( echo $md5 | grep checkfile.xml ) ]
then
    echo "There is a match"
else 
    echo "There is no match"
    rm -v "$p"
fi

If it match do nothing If it don't match then delete the file

Aucun commentaire:

Enregistrer un commentaire