How to Get Yesterday's Date in Bash on Mac and Ubuntu
In Bash scripting, there are various ways to retrieve yesterday’s date on both Mac and Ubuntu systems. Below, we’ll demonstrate two different methods for each operating system.
Mac:
Method 1: Using date with -v option
|
|
In this method, we use the -v option with the date command to subtract 1 day from the current date and format it as %F, which gives the date in YYYY-MM-DD format.