0

If possible I would to try and stay in sed, as I am trying to learn it now. I want to define 4 different variables for 4 different time slots in a bash script but don't know where to begin. I would like to have the variables as follows:

$Shift1 = 00:00:00 - 05:59:59
$Shift2 = 06:00:00 - 11:59:59
$Shift3 = 12:00:00 - 17:59:59
$Shift4 = 18:00:00 - 23:59:50

Eventually I want to use the variables based on the current time. For example, if the current time is 17:05:26 variable to be used is $Shift3 and echo the variable to a csv file row along with a date and time. Any suggestions on where I could begin?

I have been reading the sed manual for almost 2 hours and can't figure it out. What I am hoping for more than anything is something that is simple enough and in a HUMAN language that could easily be edited. For example I worry that a few months down the road the time slot might change and shift1 might no longer be starting at midnight, so I would like to be able to understand the syntax enough to edit the hours as needed in the future.

Jae Nulton
  • 373
  • 1
  • 6
  • 13
  • 1
    it would be complex expression using sed .. why not just use simple linux comparison command like here http://stackoverflow.com/questions/13516000/how-to-compare-two-dates-using-unix-commands – mebada Jun 27 '16 at 02:31
  • I am trying really hard to understand sed is the main reason. Many of the math functions I have been asking about and reading about often lend themselves to awk or perl and are much simpler than sed. Just trying to figure where sed fits in. :) – Jae Nulton Jun 27 '16 at 02:42

0 Answers0