Mkdir folder with older date

Status
Not open for further replies.

Fred

Moderator
I would like to create a folder that says the date for the day before.

I know I can:
Code:
mkdir foldername-`date +%m.%d.%Y`

But that will only give me today's date. Does anyone know how to do a similar run the command with similar output but with the date for the day before?
 
If you want an arbitrary date, just use the -d flag and give it a string like YYYY-MM-DD:
Code:
$ date -d 2010-02-19
Tue Feb 19 00:00:00 PST 2010
Or if you want "yesterday" (for example, in an automated script), it's
Code:
date -d "1 days ago"
That would make your command something like:
Code:
mkdir foldername-`date -d "1 days ago" +%m.%d.%Y`
 
Status
Not open for further replies.
Back
Top