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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:38:44+00:00 2026-05-11T08:38:44+00:00

Dear all, I am writing a python program that is retrieving edifact log messages

  • 0

Dear all, I am writing a python program that is retrieving edifact log messages from a .gz file… An example of 2 logs are the following:

2009/03/02 12:13:59.642396 siamp102 mux1-30706 Trace name: MSG Message sent [con=251575 (APEOBEinMux1), len=2106, CorrID=000182C42DE0ED] UNB+IATB:1+1ASRPFA+1A0APE+090302:1213+0095JQOL2  2009/03/02 12:14:00.029496 siamp102 mux1-30706 Trace name: MSG Message sent [con=737 (APIV2_1), len=22370, CorrID=000182C42DE0ED] UNB+IATB:1+1ASIFQLFS+1ARIOFS+090302:1214+0122V11ON9 

I would like to write a regular expression able to match some field from the first line, some from the second and some other from the third …

Is there any way to write a regular expression to be used with GREP that matches field from consecutive lines ??

Thanks in advance !!!

  • 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. 2026-05-11T08:38:44+00:00Added an answer on May 11, 2026 at 8:38 am

    With grep alone, I think this is not possible. I would suggest awk or perl in order to be able to save some context from previous lines.

    In perl this gives something like:

    #!/usr/bin/env perl  $isInLogSection = 'NO'; while (<>) {     if ( /siamp102/ ) {         # Start of log section: retrieve its ID         $isInLogSection = 'YES';         split;         $logSectionID = $_[0];     }      if ($isInLogSection eq YES && /len=/) {         # Retrieve value of len         ...     }      if ( /^$/ ) {         # End of log section         $isInLogSection = 'NO';     } } 

    In awk this gives something like:

    BEGIN { isInLogSection = 'NO'; } /siamp102/ { isInLogSection = 'YES'; logSectionID = $1; } /len=/ { if (isInLogSection == 'YES') { #retrieve len value } } /^$/ { isInLogSection = 'NO' } 

    I am not 100% certain of the exact syntax. This is mainly a canvas for illustrating the principles.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You'll need to configure IIS to send requests for your… May 12, 2026 at 8:53 pm
  • Editorial Team
    Editorial Team added an answer The problem is that your not correctly using KVC. There… May 12, 2026 at 8:53 pm
  • Editorial Team
    Editorial Team added an answer Well, here's another example. Xfire is a chat program that… May 12, 2026 at 8:53 pm

Related Questions

I am writing an application that is hidden most of the time but sometimes
Dear all, I have a question about Facebook Page: ( NOT user profile page,
Dear all: In advance, thank you for your time. Lately, I have decided to
Hey all. I am working on a project for school where we are given

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.