Here is my script. I need to subtract 7 days from today's date and use it in a file name. I am using a Mac.
#/bin/bash
DATE=$(date -d "-7 days")
echo $DATE
When I run this .sh script, I get this:
$ /Users/xxxxxxx/xxxxxxxx/dateTest.sh
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
Best Answer
With
BSD date
you need a different syntax:On my FreeBSD
man date
includes: