Find the answer to your Linux question:
Results 1 to 7 of 7
Sould be very easy. If I have `date '+%d-%B-%Y'` in a shell script, and have: echo `date '+%d-%B-%Y'` It will show 21-April-2005 I would like it to show 21-04-2005, and ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Posts
    3

    help with `date '+%d-%B-%Y'`


    Sould be very easy. If I have `date '+%d-%B-%Y'` in a shell script, and have:

    echo `date '+%d-%B-%Y'`

    It will show 21-April-2005

    I would like it to show 21-04-2005, and need it also to read 21-4-2005, 21-04-05

    Thanks for you help.

    -Jeremy

  2. #2
    Linux Guru
    Join Date
    Mar 2003
    Location
    Wisconsin
    Posts
    1,907
    How about

    %d-%m-%y

    http://unixhelp.ed.ac.uk/CGI/man-cgi?date

    BTW... Excellent name, dude.



    Jeremy
    Registered Linux user #346571
    "All The Dude ever wanted was his rug back" - The Dude

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Posts
    3
    Quote Originally Posted by jeremy1701
    BTW... Excellent name, dude.



    Jeremy
    Very Good. That made my day, post a message, and see the response from myself Just Kidding

    Thanks for the url. But I see one thing wrong, I do it see anywhere to do like 4-21-2005 or 4-21-05, what about some where in the script to look for 01 -09 and take the 0 off?

    -Jeremy

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Mar 2003
    Location
    Wisconsin
    Posts
    1,907
    Quote Originally Posted by jsgehris
    But I see one thing wrong, I do it see anywhere to do like 4-21-2005 or 4-21-05, what about some where in the script to look for 01 -09 and take the 0 off?
    I guess I don't understand what you're asking for here. If you want a double-digit year rather then a four digit year, use %y rather then %Y. If you need to read a date and convert it from one form to another, you're going to have to write a little code. If you need help doing that, post what you've got and we can see where you're at.

    Jeremy
    Registered Linux user #346571
    "All The Dude ever wanted was his rug back" - The Dude

  6. #5
    Just Joined!
    Join Date
    Apr 2005
    Posts
    3
    Ok, I see the year to make it 2, sorry. All I am doing is makeing dirs a cron job, and copying reports at work. They are picky about folder dates, and always say I want this and that for folder dates, and say if you can do it one way, you can do it another. The only other day format I do not see is exp 4-21-05 drop the 04. I have no clue how to do this. Makeing dirs it one thing. I know they sould not complane about the 0 but they do.

    -Jeremy

  7. #6
    Linux Guru
    Join Date
    Mar 2003
    Location
    Wisconsin
    Posts
    1,907
    I don't see it either. I think you'll have to script that one. Shouldn't be too difficult.

    Jeremy
    Registered Linux user #346571
    "All The Dude ever wanted was his rug back" - The Dude

  8. #7
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    You could probably use sed to take the 0 off the beginning. I know no sed, but I'm fairly certain that's possible in it.

    OTOH, it's quite possible in perl regexps.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

Posting Permissions

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