using stat to determine last file access and comparing to current date in IF statemnt
this was some code a friend wrote that worked on my mac os x machine
Code:
THIS_RUN=`date +%s` Code:
[museotwvee@museotwvee Webcam]$ stat -t %X last_run.txt |
oh, i got it. -c was what i was looking for...
THIS_RUN=`date +%s` FILE_TIME=`stat -c '%X' $f` if [ $FILE_TIME -lt $(($THIS_RUN - 120)) ]; then echo "$FILE_TIME is less than $THIS_RUN - 120" else echo "$FILE_TIME is not less than $THIS_RUN -120" fi thanks and sorry for bandwidth waste but maybe someone else will find it useful ;) |
arghh...
so this doesn't work now that i'm on a ubuntu machine. or at least it doesn't work on this new machine that happens to be running ubuntu 9.10 [CODE] ... FILE_TIME=`stat -c ‘%X’ $f` if [ $FILE_TIME -lt $(($THIS_RUN - 120)) ]; then echo “Uploading $f” ... [\CODE] and when i run it... [CODE] axiomtwvee@axiomtwvee:~/Videos/Webcam$ ./videochecker.sh ./videochecker.sh: line 93: [: ‘1266337825’: integer expression expected [\CODE] so something about my syntax is slightly off. i've tried a lot of permutation here but can't seem to find it. i tried various parentheses modification in the variable definition and the IF statement. feels like i'm grasping for straws. there is a decent amount of variability in the references i find online for these another thing that used to work that i had to change was this line [CODE] original that worked fine before SEARCH_DIR="/home/axiomtwvee/Videos/Webcam" changed to SEARCH_DIR=/home/axiomtwvee/Videos/Webcam [\CODE] something about my shell environment is different? [CODE] axiomtwvee@axiomtwvee:~/Videos/Webcam$ echo $SHELL /bin/bash [\CODE] but it seems like the usual... any tips? thanks. |
All times are GMT -5. The time now is 06:08 PM. |