Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.

Linux : Date command

  • 27-07-2006 03:20PM
    #1
    Moderators, Recreation & Hobbies Moderators Posts: 10,912 Mod ✭✭✭✭


    Linus noob here. I have to use one at work but until last month I had never even turned a linux machine on :)

    I had a script run by crontab each evening to send a file to a client by cft (like ftp). The name of the file changes daily absed on the date.

    I've worked out that
    CFTDATE=D`date +\%d\%m\%y`
    

    assigns 260706 to the variable CFTDATE which is just perfect.

    What I need now is a way to easily come up with yesterdays date.

    Any ideas?



    EDIT: I've found the --date (1 day ago) command which does return yesterdays date but not in the form I need i.e. %d%m%y


Comments

  • Closed Accounts Posts: 437 ✭✭Yook


    This should work for ya:

    'date --date=yesterday +\%d\%m\%y'


  • Moderators, Recreation & Hobbies Moderators Posts: 10,912 Mod ✭✭✭✭Ponster


    Yook wrote:
    This should work for ya:

    'date --date=yesterday +\%d\%m\%y'

    That's just beautiful !

    Now I can leave early and go watch Superman Returns :)


    Cheers !


Advertisement