Mkdir folder with older date

Discussion in 'Linux, BSD and Other OS's' started by Fred, Feb 21, 2010.

Thread Status:
Not open for further replies.
  1. Fred

    Fred Moderator

    Likes Received:
    11
    Trophy Points:
    18
    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?
     
  2. Anti-Trend

    Anti-Trend Nonconformist Geek

    Likes Received:
    118
    Trophy Points:
    63
    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`
    
     
  3. Fred

    Fred Moderator

    Likes Received:
    11
    Trophy Points:
    18
    Thanks a lot, AT!
     
Thread Status:
Not open for further replies.

Share This Page