Discussion Locked

Yesterdays Date in Unix

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I can get today's date in the YYMMDD format with "date +%y%m%d". How can I get yesterday's date in the same format?

5 replies

by cpfeiffe

I'm assuming you have this in a script and a variable is set for the date. If so you can just do eval $date -1 for yesterday. If this is not in a script you can still use the eval and some piping on the command line. This varies depending on whatshell you are using, but here is one example:
date +%y%m%d |xargs eval {} -1 \;

This discussion is closed to new replies.