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

  • SEARCH
  • Home
  • 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 8928423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:26:00+00:00 2026-06-15T08:26:00+00:00

I am currently working on a script which processes a csv file, and corrects

  • 0

I am currently working on a script which processes a csv file, and corrects certain aspects of them along the way. One of the things that it does is correct time format if needed. Two type of conversion takes place:

 xx:xx:xx to PTxxHxxMxxS
 10:03:45 to PT10H03M45S

I’ve have been able to do this using the following (see below) although I am trying to find out how to do it either using sed or awk in order to speed up the process. In addition to the actual conversion process, I would also like to keep count of the changes that are made (so say 4 times values are converted, a counter would be incremented to 4), which I have been able to do easily with the if statement below (though it is not shown), although I would not know much about doing that using sed/awk.

 istimef=$( echo "$Sfcpp6" | grep ".*:.*:.*" )
                    if [ "$istimef" != "" ]; then
                            hs=$( echo "$Sfcpp6" | cut -d ':' -f 1 )
                            mn=$( echo "$Sfcpp6" | cut -d ':' -f 2 )
                            sc=$( echo "$Sfcpp6" | cut -d ':' -f 3 )
                            Sfcpp6=$( echo "PT"$hs"H"$mn"M"$sc"S" )
                            echo "$Sfcp6"
                    fi

which essentially checks if the time value is even there, and then performs the conversion.

  • 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-15T08:26:01+00:00Added an answer on June 15, 2026 at 8:26 am

    sed solution: uses \(...\) to capture the numbers, character classes [0-9] to match any digit.

    sed 's/\([0-9][0-9]\):\([0-9][0-9]\):\([0-9][0-9]\)/PT\1H\2M\3S/'
    
    • 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 currently working on a script which should analyze a dataset based on a
I have a simple script which copies a file from one SMB mount to
I`m currently working on a script, and I have the following situation. function somnicefunction()
I'm currently working on a PowerShell script to analyse VPN traffic by reading the
I'm currently working on a jQuery script that will translate the site's text into
We currently have a working php mail script, this works fine and as we
I'm working currently on a long polling script where i've to check a database
Case Currently I'm working on database seeding script, executed with sqlcmd . For example
I am working on a AJAX/jquery notification script. Currently it retunrs a whole fhtml

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.