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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:57:26+00:00 2026-05-12T11:57:26+00:00

I need to search for a pattern in files. For example the content of

  • 0

I need to search for a pattern in files.
For example the content of the file is below:

3555005!K!00630000078!C!20090805235959!47001231000000!16042296!336344324!A!1!ENG!0!00630000078!NO!00630000078!
3555005!K!204042880166840!I!20090805235959!47001231000000!16042296!336344324!A!1!ENG!0!00630000078!NO!00630000078!
3555005!D!16042296!DUMMY!20090805235959!0!47001231000000!0!336344324!1!1!POST!USAGE!336344324!0!
3555005!C!336344324!1!!!EUR!1!1!!I!
3555005!S!00630000078!20090805172515!LF010300!

Here I want to search for lines with !D! and the 7th field in the line is less than the system date, then I want to delete the line and save the file.

Is that possible?

  • 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-12T11:57:27+00:00Added an answer on May 12, 2026 at 11:57 am

    If you prefer AWK…

    awk -f logstrip.awk  in.log > out.log
    

    where logstrip.awk looks something like

    # *** Simple AWK script to delete lines from log file ***
    #    Rule: keep all lines except these that have their 2nd
    #          field equal to "D" and their 7th field more than
    #          current date time
    
    
    BEGIN {
        FS = "!";   #delimiter
    
        stopDate = systime();
        # stopDate = 47001231000001;   for test purposes
    
        deletedLineCtr = 0;   #diagnostics counter, unused at this time
    }
    
    {
      if (match($2, "D") && ($7 < stopDate) ) {
        deletedLineCtr++;
      }
      else
         print $0
    }
    

    should do the trick.

    Attention, however, your field #7 contains an odd date format. I think I recognize an recent epoch value (123…) but it is preceded by 4 apparently unrelated digit. These can easily be removed before comparing to StopDate

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

Sidebar

Ask A Question

Stats

  • Questions 223k
  • Answers 223k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can't call an other controller's action method. You have… May 13, 2026 at 12:40 am
  • Editorial Team
    Editorial Team added an answer It should just be import [namespace] for common .NET libraries… May 13, 2026 at 12:40 am
  • Editorial Team
    Editorial Team added an answer We faced the same exact issue two months back, I… May 13, 2026 at 12:40 am

Related Questions

I need to search for files in a directory that begin with a particular
I have recently started learning Perl and one of my latest assignments involves searching
I would like to be able to search a string for various words, when
I am a graduate student of physics and I am working on writing some

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.