Note that there are some explanatory texts on larger screens.

plurals
  1. POPerl cmd option for printing first string from a matched line
    primarykey
    data
    text
    <p>I have a text file as input like this:let say it as xyz.txt</p> <pre><code>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 </code></pre> <p>Requirement: I like to extract the first numeric strings (TIME) from lines that contains the SR "1" and TYPE as "Rx" </p> <p>I hardly know perl and tried a command by reading on internet i.e:</p> <pre><code>perl -nle "print if /"1"\s(.+?)"Rx"/" xyz.txt &gt;&gt;output.txt </code></pre> <p>for extracting matched lines </p> <p>The output i got in output.txt is: </p> <pre><code>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 </code></pre> <p>Desired output(Requirement) are only these:</p> <pre><code>2.050265 2.050887 </code></pre> <p>The complete information about above two value are from xyz.txt :</p> <pre><code>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 </code></pre> <p>help me....what changes i need to do, so that it will satisfy:</p> <p>a. consider only "1" from Rx row and not from No row in xyz.txt file.</p> <p>b. Remove all except first string in output.txt</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload