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 6788027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:26:09+00:00 2026-05-26T17:26:09+00:00

I have a large txt file space delimited which I split into 18 smaller

  • 0

I have a large txt file space delimited which I split into 18 smaller files (each with their own number of columns). This split is based on a delimiter i.e. whenever the timestamp hits midnight. So effectively, I’ll end up with a 18 files in the form of (note, ignore the dashes and pipes, I’ve used them to improve the readability):

file1

time ----------- valueA - valueB  
12:00:00 AM |      54.13 | 239.12  
12:00:01 AM |      51.83 | 119.93  
..  

file18

time ---------- valueA - valueB - valueC - valueD  
12:00:00 AM |      54.92 | 239.12  | 231.23  | 882.12  
12:00:01 AM |      23.92 | 121.92  | 201.23  | 892.12   
..  

Once I split the file I then perform some processing on each of the files using AWK so in short there’s 2 stages the ‘split stage’ and the ‘processing stage’.

Unfortunately, the timestamp contained in the large txt file is in 1 of 2 formats. Either the desirable 24 hour format of “00:00:01” or the undesirable 12 hour format of “12:00:01 AM”.

As a result, I’m trying to convert all formats to be 24 hours and I’m not sure how to do this. I’m also not sure whether to attempt this at the split stage using bash or at the process stage using AWK. I know that the following function converts 12 hour to 24 hr

'date --date="12:00:01 AM" +%T'

however, I’m not sure how to incorporate this into my shell script were I’m using ‘while read line’ at the ‘split stage’ or whether I should do the time conversion in AWK (if possible?) at the ‘processing stage’.

  • 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-05-26T17:26:09+00:00Added an answer on May 26, 2026 at 5:26 pm

    see the test below, is it helpful for you?

     kent$  echo "12:00:00 AM |      54.92 | 239.12  | 231.23  | 882.12  "\
    |awk -F'|' 'BEGIN{OFS="|"}{("date --date=\""$1"\" +%T") |getline $1;print }'
    

    output

     00:00:00|      54.92 | 239.12  | 231.23  | 882.12
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several large files, each of which I want to chunk/split it in
I have this large txt file 8mb+ that is delimited and I need to
I have multiple (many) files; each very large: file0.txt file1.txt file2.txt I do not
Imagine we have a piece of code which cuts the large data into smaller
I have a large text file of records, each delimited by a newline. Each
I have quite a large list of words in a txt file and I'm
I have this large (and oddly formatted txt file) from the USDA's website. It
I have a txt file that I’m trying to import as flat file into
I have a large tab delimited text file, for example, call it john_file: 1
I have a large string text file, I would like to split the string

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.