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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:42:01+00:00 2026-05-31T00:42:01+00:00

I have a text file as input like this:let say it as xyz.txt TIME

  • 0

I have a text file as input like this:let say it as xyz.txt

TIME    SR No               TYPE DATA

2.046103 1  1               Tx   d 8 01 01 01 99 9A 9B 9C 9D
2.046163 3  1               Rx   d 8 01 01 01 99 9A 9B 9C 9D
2.046361 2  1               Rx   d 8 01 01 01 99 9A 9B 9C 9D
2.046916 1  3               Tx   d 8 01 01 01 9B 9C 9D 9E 9F
2.046977 3  3               Rx   d 8 01 01 01 9B 9C 9D 9E 9F
2.047177 2  3               Rx   d 8 01 01 01 9B 9C 9D 9E 9F
2.048034 1  5               Tx   d 8 01 01 01 AD AE AF B0 B1
2.048095 3  5               Rx   d 8 01 01 01 AD AE AF B0 B1
2.048295 2  5               Rx   d 8 01 01 01 AD AE AF B0 B1
2.050006 1  8               Tx   d 8 01 01 01 B1 B2 B3 B4 B5
2.050065 3  8               Rx   d 8 01 01 01 B1 B2 B3 B4 B5
2.050265 1  8               Rx   d 8 01 01 01 B1 B2 B3 B4 B5
2.050632 2  601             Rx   d 8 01 01 01 CA CB CC CD CE
2.050690 3  700             Rx   d 8 01 01 01 CA CB CC CD CE
2.050887 1  700             Rx   d 8 01 01 01 CA CB CC CD CE

Requirement: I like to extract the first numeric strings (TIME) from lines that contains the SR “1” and TYPE as “Rx”

I hardly know perl and tried a command by reading on internet i.e:

perl -nle "print if /"1"\s(.+?)"Rx"/" xyz.txt >>output.txt

for extracting matched lines

The output i got in output.txt is:

2.046163 3  1               Rx   d 8 01 01 01 99 9A 9B 9C 9D
2.046361 2  1               Rx   d 8 01 01 01 99 9A 9B 9C 9D
2.050265 1  8               Rx   d 8 01 01 01 B1 B2 B3 B4 B5
2.050632 2  601             Rx   d 8 01 01 01 CA CB CC CD CE
2.050887 1  700             Rx   d 8 01 01 01 CA CB CC CD CE

Desired output(Requirement) are only these:

2.050265              
2.050887 

The complete information about above two value are from xyz.txt :

2.050265 1  8               Rx   d 8 01 01 01 B1 B2 B3 B4 B5
2.050887 1  700             Rx   d 8 01 01 01 CA CB CC CD CE

help me….what changes i need to do, so that it will satisfy:

a. consider only “1” from Rx row and not from No row in xyz.txt file.

b. Remove all except first string in output.txt

  • 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-31T00:42:02+00:00Added an answer on May 31, 2026 at 12:42 am

    I would avoid regexes as being hard to maintain.

    perl -lne '@a=split; print "$a[0]" if (($a[1] == 1) and ($a[3] eq "Rx"))'
    

    Explanation:

    • split — splits your line into tokens, separated by whitespace.
    • print “$a[0]” — prints the first token
    • $a[1] == 1 — evaluates if the 2nd token evaluates numerically to 1
    • $a[3] eq “Rx” — evaluates if the 4th token equals the string Rx.

    Also, the command line switches:

    • -l causes perl to process lines similar to awk/sed (ignores leading/trailing whitespace)
    • -n causes perl to apply the perl program to each line of input
    • -e supplies the perl code to execute on the command line, as the next argument.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have an input: <input type=text id=smth value= /> and I have
I' ve got a problem with Haskell. I have text file looking like this:
I have a text file of e-mails like this: 10:info@example.com;dev@example.com 12:john@host.com; George <g.top@host.com> 43:jim.p@web.com.;sue-allen@web.com
I have a text file that looks like this: i 3755 i 3633 i
I have a text file that looks like this: BALLOTS CAST Riding 0 YES
I have a text file having numbers like this +12345678912 (start with + and
I have a linux utility that parses structured input ( a text file ),
Input: I have a LaTeX file, with plain text & math formulas. Desired output:
I have text file with some stuff that i would like to put into
I have text file with something like first line line nr 2 line three

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.