Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8887233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:45:22+00:00 2026-06-14T21:45:22+00:00

I am currently working on a script that processes and combines several different files,

  • 0

I am currently working on a script that processes and combines several different files, and for the one part, it is necessary that I find the difference between two different times in order to determine a “total” amount of time that someone has worked. the times themselves are in the following format

 34:18:00,40:26:00,06:08:00

with the first one being start time, second end time, third total time. Although this one is displayed correctly, there are some entries that need to be double checked and corrected (the total time is not correct based on the start/end time). I have found several different solutions in other posts but most of them also include dates and such too (most of them using awk), I am not experienced with awk so am not sure how to go about removing the date portion from those examples. I have also heard that I could convert the times to unix epoch time, but I was just curious if there were any other ways to accomplish this, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:45:24+00:00Added an answer on June 14, 2026 at 9:45 pm

    Something like this might help you:

    #!/bin/bash
    
    time2seconds() {
       a=( ${1//:/ } )
       echo $((${a[0]}*3600+${a[1]}*60+${a[2]}))
    }
    seconds2time() {
       printf "%.2d:%.2d:%.2d" $(($1/3600)) $((($1/60)%60)) $(($1%60))
    }
    
    IFS=, read start stop difference <<< "34:18:00,40:26:00,06:08:00"
    
    printf "Start=%s\n" "$start"
    printf "Stop=%s\n" "$stop"
    printf "Difference=%s (given in file: %s)\n" $(seconds2time $(($(time2seconds $stop)-$(time2seconds $start)))) "$difference"
    

    Output is:

    Start=34:18:00
    Stop=40:26:00
    Difference=06:08:00 (given in file: 06:08:00)
    

    Note: there’s nothing that checks if the times are in a valid format, I don’t know how reliable your data are.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a script which processes csv files, and one of
I'm working on a script that currently has: my @files = `$some_command`; print @files;
I'm currently working on a jQuery script that will translate the site's text into
I'm currently working on a minimal shop(-ish) script that has to deal with a
I'm currently working on a PHP/MySQL script that does the following, in this order:
Intro Currently I am working with XML files. With PHP I combine several XML
I currently have a shell script that process many images one after the other,
I´m currently working on a short SED script that needs to HTML-encode parts of
I'm working on a script in R that processes some data and writes an
I am currently working on a script which processes a csv file, and corrects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.