mercredi 7 octobre 2015

Search for a file by the date of it

I'm doing a Script which should search in a path for a File by its Date. I tried it with the name itself because in there is a Date too. (For Example: stargate_speedtests_2015-10-07-09:03:01) And after I get the File i want to Zip it.

datetoday="date '+%Y-%m-%d'"
LOCATION="/data/outgoing/cnlab/"
FILENAME="$LOCATION/stargate_speedtests_$datetoday"


if ((-f ${FILENAME[@]} ))
    then        
        tar -czf $FILENAME.tar.gz $FILENAME.csv

        find . -name '$FILENAME' -maxdepth 1 -print0 | 
        tar -czf "$FILENAME".tar.gz --null -T -
        ZIP="$FILENAME.tar.gz"
else 
        echo "$FILENAME not found"
fi 

Aucun commentaire:

Enregistrer un commentaire