Here is what my current code is and haven't been able to figure out a solution. So here is the code:
#!/bin/bash
DATE_TIME=`date +%s`
FILE_OUTPUT=`ls -l --time-style=long-iso /data | grep drwxrwxrwx | awk '{print $6,$7","$8","}'`
rm -rf /tmp/tmp_direc_last_update.log
echo "$FILE_OUTPUT" > /tmp/tmp_direc_last_update.log
ADD_EPOCH=`sed -e "s/$/"$DATE_TIME",/" -i /tmp/tmp_direc_last_update.log`
FINAL_FILE=`cat /tmp/tmp_direc_last_update.log`
echo "$FINAL_FILE" > /data/stats/direc_last_update.log
What I need to do is to check if the /tmp/tmp_direc_last_update.log is empty and if it is, don't do any of the last three lines of code.
I've tried putting a if statement with [ -s /tmp/tmp_direc_last_update.log] but I always get an error saying that I'm missing a ']'.
My linux bash scripting skills are not that great, so any help anyone could assist with would be greatly appreciated.
Thanks!