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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:04:06+00:00 2026-06-12T01:04:06+00:00

Writing script in AWK – input data – time in format 31.12.2012 . I

  • 0

Writing script in AWK – input data – time in format 31.12.2012. I want to compare 2 dates – system date and this date. I think the best way is to convert both dates into unix timestamp, make deduction and then compare with conditional. Date can be converted into unix timestamp only with this format 2012-12-31 . To convert into this format I write SED expression sed -n -e "s_\(..\)\(.\)\(..\)\(.\)\(....\)_\5-\3-\1_p". And then we must convert this expression with command date --utc --date "2012-12-31" +%s. But pipes doesnt want to work.

In the AWK i wrote:


#/usr/bin/awk -f
BEGIN {
    FS=",";
}
{
    split($3, account, "/");
    gsub(/ $/, "", account[1]);
    split($4, products, "\\\\n");
    split($5, supports, "\\\\n");
    for (i in products) {
        gsub("\"", "", products[i]);
        gsub("\"", "", supports[i]);
        split(supports[i], timesupport, "\ > ");
        "date +%s" | getline dateVal;
        print timesupport[1] | sed -n -e "s_\(..\)\(.\)\(..\)\(.\)\(....\)_\5-\3-\1_p" | getline timeVal1 | date --utc --date "timeVal1" +%s | getline timeVal;
        x=dateVal - timeVal;
        if (supports[i] !~ /n\\\\a*/ && supports[i] !~ /n\/a*/ && $2 !~ /\NULL/)
            print $1","$2","timesupport[1]","account[1]"\","products[i]"\","$6;

    }
}

The main thread was in post 12634588. 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-12T01:04:07+00:00Added an answer on June 12, 2026 at 1:04 am

    Why not use the builtin time functions:

    (echo | awk '{ print systime() }'; date +%s)
    1348915323                
    1348915323
    

    To convert the string you mentioned to the same format, use mktime:

    { 
      t = "31.12.2012"
      split(t, a, "\\.")
      ts = sprintf("%04d %02d %02d 00 00 00", a[3], a[2], a[1])
      print mktime(ts)
    }
    

    Output:

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

Sidebar

Related Questions

this is my first time writing script for cron job. I wrote my code
I am writing shell script first time, I want to download latest create file
I am writing a awk script that takes some columns of input in a
When writing a script that loads data, it's a waste of time to wait
I am writing an awk script wherin I want to search for some strings
I am writing an AWK script which takes a list of dates and formats
I am writing script, I need to use sed for changing somefiles, I want
Im writing a script that should do this... chroot /chroot_dir/ su - ./startup.sh (This
I am currently writing an awk script within a bash script. One of my
I am writing a bash script that modifies a file that looks like this:

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.