Find the answer to your Linux question:
Results 1 to 4 of 4
How do I create directory in Linux with Current year and last month. (I'll run this every month as a cronjob)...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2013
    Posts
    1

    Question How create directory in Linux with Current year and last month


    How do I create directory in Linux with Current year and last month. (I'll run this every month as a cronjob)

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,380
    Hi and welcome

    This should do it:
    Code:
    mkdir -p $(date "+%Y-%B" --date "1 month ago")
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Apr 2013
    Posts
    1
    Quote Originally Posted by Irithori View Post
    Hi and welcome

    This should do it:
    Code:
    mkdir -p $(date "+%Y-%B" --date "1 month ago")
    It Works, Thanks!

  4. #4
    Just Joined!
    Join Date
    Aug 2006
    Posts
    16

    Or you could use touch

    Quote Originally Posted by heshandh View Post
    How do I create directory in Linux with Current year and last month. (I'll run this every month as a cronjob)
    This applies to any existing file or directory: use
    Code:
    touch
    with either the
    Code:
    -a -d or -m
    options.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •