change time automaticlly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • quartz
    New Member
    • Aug 2007
    • 19

    change time automaticlly

    I wont to create shell scripts which will be able to change days in month, every day, automatically.
    .
    .
    extdate=2007082 500
    .

    it is: year, month, day, and start time.

    I need to be able to change to: 26, 27, 28,...,

    Thanks in advance,
  • arne
    Recognized Expert Contributor
    • Oct 2006
    • 315

    #2
    Originally posted by quartz
    I wont to create shell scripts which will be able to change days in month, every day, automatically.
    .
    .
    extdate=2007082 500
    .

    it is: year, month, day, and start time.

    I need to be able to change to: 26, 27, 28,...,

    Thanks in advance,
    You mean you want a variable that stores the date in a certain format?
    Have a look at the 'date' command then:

    Code:
    #!/bin/sh
    
    date=`date +%Y%m%d%k%M`
    echo $date 
    
    date=`date --date=070825 +%Y%m%d`
    echo $date
    Otherwise explain a little more what you need.

    HTH,
    arne

    Comment

    • quartz
      New Member
      • Aug 2007
      • 19

      #3
      Into one shell script I need to set up start date manually (it is one NWP model)

      some commands

      startdate=20070 80106 (for instance)

      another commands

      need to figure out how to change days in month, remove 01 and change to 02, 03, ...and every day. when finish all days for that month then change the month 08 to 09??

      Thanks

      Comment

      • quartz
        New Member
        • Aug 2007
        • 19

        #4
        According to your suggestion I get it what I looking for:

        date = `date + «'%Y-%m-%d_00:00:00'»`
        echo start_date = $date

        result is:

        start_date = '2007-29-08_00:00:00',

        that is it!!

        How to get next day???

        2007-30-08_00:00:00

        Next thing how this implement in some text on the specific place. I have in the namelist:

        start_date = '2007-28- 08_00:00:00'.

        end_date = '2007-29-08_00:00:00',

        I need to replace this two lines and get it, of course not affecting to other text in the same file:

        start_date = '2007-29- 08_00:00:00',

        end_date = '2007-30-08_00:00:00',

        Thanks a lot for your help!!

        Comment

        Working...