Skip to content

Instantly share code, notes, and snippets.

@treefitty
Created February 1, 2019 05:46
Show Gist options
  • Save treefitty/98626b864c846ad836cbd4cdbccb8247 to your computer and use it in GitHub Desktop.
Save treefitty/98626b864c846ad836cbd4cdbccb8247 to your computer and use it in GitHub Desktop.
Copies a file to another file with yesterday's date - used for a rudimentary todo history tracker when I work
# Get yesterday's date (different between Mac and Linux)
if [[ "$OSTYPE" == "darwin"* ]]; then
yesterday=`date -v-1d +%F`
else
yesterday=$(date -d "yesterday 13:00" +'%Y%m%d')
fi
# Construct the filename
dest=past-$yesterday.md
# Make sure the script hasn't already been run today
if [ -e $dest ]; then
echo "ERROR: todo already moved on"
else
cp -n _today.md $dest
fi
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment