Find the answer to your Linux question:
Results 1 to 5 of 5
hi, bit of a noob question here, but in the absence of any disk-level resilience, i'm trying to dump a database to file every hour. i want to rotate the ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    2

    extracting 24hr time from date(): grep or sed?

    hi, bit of a noob question here, but in the absence of any disk-level resilience, i'm trying to dump a database to file every hour. i want to rotate the files by extracting the 24 hour time from date() and embedding it in the file name.
    i've tried the following to extract, but have a feeling i'm somewhat misguided here :
    Code:
    TIMESTAMP=$(date)  
    sed $TIMESTAMP s'/^*\d\d:\d\d.*/g'
    ...grateful for any thoughts or suggestions.

  2. #2
    Just Joined!
    Join Date
    Aug 2007
    Posts
    37
    Couldn't you just use date's built-in formatting?
    Code:
    TIMESTAMP=$(date +"%R")

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Posts
    2
    ...er, yep.
    right under the proverbial.

    thanks for the steer

  4. #4
    Just Joined!
    Join Date
    Jan 2012
    Posts
    1

    24hr parsing

    Newbie to this site. I'm curious what your final script was to parse date 24hrs?

    thanks.

  5. #5
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,096
    Hello and welcome, tobius74!

    This thread is well over 4 years old so I'm going to lock it but please feel free to start a fresh thread if you need any help with Linux.

    Thanks!
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

Posting Permissions

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