I am new to bash scripts and trying to work with an if statement.
I want to check to see if there is a + or - 5 minutes file date stamp from the point in time. I still:
#!/bin/bash MODDATE=$(stat -c '%y' test.txt) echo moddate= $MODDATE MODDATE=$(echo $MODDATE |head --bytes=+16) echo now = $MODDATE currentdate2=$(date -d "+5 minutes" '+%Y-%m-%d %H:%M') currentdate3=$(date -d "-5 minutes" '+%Y-%m-%d %H:%M') echo currentdate2 = $currentdate2 echo currentdate3 = $currentdate3
So this gives me the file date (MODDATE) and the date is now + or - 5 minutes.
How can I do an IF statement to say "if $ MODDATE is between $ currentdate2 (+5 minutes from now) and $ currentdate3 (after -5 minutes)" then echo [1]> output.txt ELSE echo [0] > output.txt.
Thanks for your help in advance.
source share