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 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

Related Questions

I need to create a script to search through just below a million files
I need a regex pattern, that will search the file for lines where something
I need to search a string and replace all occurrences of %FirstName% and %PolicyAmount%
I need to search a string in the string array. I dont want to
I need to search across multiple columns from two tables in my database using
I have a multidimensional array. I need to search it for a specific range
Problem I have timestamped data, which I need to search based on the timestamp
I need to recursively search directories and replace a string (say http://development:port/URI ) with
I need a binary search algorithm that is compatible with the C++ STL containers,
I need to add full web search to my site. I need something like

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.