Skip to content

Instantly share code, notes, and snippets.

@akarca
Created March 25, 2018 00:08
Show Gist options
  • Save akarca/f0619406f9e808cdb9c1939e674f8cb1 to your computer and use it in GitHub Desktop.
Save akarca/f0619406f9e808cdb9c1939e674f8cb1 to your computer and use it in GitHub Desktop.
getting yesterday's timestamp with date command on mac and linux
#!/bin/bash
unameOut="$(uname -s)"
case "${unameOut}" in
Darwin*) yesterday=$(date -v-1d "+%s");;
*) yesterday=$(date +%s --date="-1 days");;
esac
echo $yesterday
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment