Skip to content

Instantly share code, notes, and snippets.

@dewomser
Last active August 20, 2023 21:07
Show Gist options
  • Save dewomser/e8fd35b249667f4912cb21de4753c188 to your computer and use it in GitHub Desktop.
Save dewomser/e8fd35b249667f4912cb21de4753c188 to your computer and use it in GitHub Desktop.
File last modified today? Bashscript
# Get the last modification time of the file in seconds
last_modified=$(stat -c "%Y" $file)
# Read the previous value from ~/temp/letzter.txt
previous_modified=$(cat ~/temp/letzter.txt)
# Compare the last and previous values
if [ $last_modified -gt $previous_modified ]; then
echo "The file has changed"
else
echo "The file has not changed"
fi
# Write the last value to ~/temp/letzter.txt
echo $last_modified > ~/temp/letzter.txt
#!/bin/bash
# Löok if there is an update for $test available today
test=https://lua.rlp.de/fileadmin/lua/Downloads/Corona/Listen/Fallzahlen_und_Todesfaelle_Corona_RLP.xlsx
codate1=$(curl -sI $test | grep -i 'Last-Modified:'|grep -E -o "[0-9]{2}[[:blank:]][[:alpha:]]{3}[[:blank:]][0-9]{4}")
date1=$(LC_ALL=C date '+%d %b %Y' -u)
#echo $codate1 $date1
if [[ "$date1" = "$codate1" ]]
then
echo "file is modified today"
else
echo "file is NOT modified today"
# sleep 10
exit
fi
@dewomser
Copy link
Author

sleep 10 not necessary

@dewomser
Copy link
Author

Do not know wether modified_by_Bingchat.sh works. But looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment