text: user856: I have following example data from a large file.
  cont100 1128 1125
  cont1005 3642 3642
  cont1006 103 19
  cont1037 3146 3146
  cont104 895 890
  cont1056 934 934
  cont1059 1750 1750
  cont1072 2577 2577
  cont1078 43 42
  cont1081 727 2
  
  I need to get only the rows with similar values in column 2 and column 3. The output should be like this.
  cont1005 3642 3642
  cont1037 3146 3146
  cont1056 934 934
  cont1059 1750 1750
  cont1072 2577 2577
  
  Also I need to get the inverse of that. That means I need to get the rows with values that are not similar in the columns. The output should be like this.
  cont100 1128 1125
  cont1006 103 19
  cont104 895 890
  cont1078 43 42
  cont1081 727 2
  
  
  user6251: The Perl solution is similar to the awk solution from MaximilianPress:
  Print lines with identical values in columns 2 and 3:
  perl -lane 'print if $F[1] == $F[2];' in.txt
  
  # Prints:
  cont1005 3642 3642
  cont1037 3146 3146
  cont1056 934 934
  cont1059 1750 1750
  cont1072 2577 2577
  
  Print lines with different values in columns 2 and 3:
  perl -lane 'print if $F[1] != $F[2];' in.txt
  
  # Prints:
  cont100 1128 1125
  cont1006 103 19
  cont104 895 890
  cont1078 43 42
  cont1081 727 2
  
  The Perl one-liner uses these command line flags:
  -e : Tells Perl to look for code in-line, instead of in a file.
  -n : Loop over the input one line at a time, assigning it to $_ by default.
  -l : Strip the input line separator ("\n" on *NIX by default) before executing the code in-line, and append it when printing.
  -a : Split $_ into array @F on whitespace or on the regex specified in -F option. Arrays in Perl are 0-indexed.
  SEE ALSO:
  perldoc perlrun: how to execute the Perl interpreter: command line switches
  
  user2108: I think it is easy to do with awk, e.g. see here.
  For your example, with your data in file:
  %  awk '$2 != $3 {print $0}' file
  # outputs
  cont100 1128 1125
  cont1006 103 19
  cont104 895 890
  cont1078 43 42
  cont1081 727 2
  
  %  awk '$2 == $3 {print $0}' file
  # outputs:
  cont1005 3642 3642
  cont1037 3146 3146
  cont1056 934 934
  cont1059 1750 1750
  cont1072 2577 2577
  
  
  Note that where you say "similar" I am interpreting that to mean "exactly the same", because that is the case in your example.
  
original_text: 856: <p>I have following example data from a large file.</p>
  <pre><code>cont100 1128 1125
  cont1005 3642 3642
  cont1006 103 19
  cont1037 3146 3146
  cont104 895 890
  cont1056 934 934
  cont1059 1750 1750
  cont1072 2577 2577
  cont1078 43 42
  cont1081 727 2
  </code></pre>
  <p>I need to get only the rows with similar values in column 2 and column 3. The output should be like this.</p>
  <pre><code>cont1005 3642 3642
  cont1037 3146 3146
  cont1056 934 934
  cont1059 1750 1750
  cont1072 2577 2577
  </code></pre>
  <p>Also I need to get the inverse of that. That means I need to get the rows with values that are not similar in the columns. The output should be like this.</p>
  <pre><code>cont100 1128 1125
  cont1006 103 19
  cont104 895 890
  cont1078 43 42
  cont1081 727 2
  </code></pre>
   6251: <p>The Perl solution is similar to the awk solution from <em>MaximilianPress</em>:</p>
  <p>Print lines with identical values in columns 2 and 3:</p>
  <pre><code>perl -lane 'print if <span class="math-container">$F[1] == $</span>F[2];' in.txt
  
  # Prints:
  cont1005 3642 3642
  cont1037 3146 3146
  cont1056 934 934
  cont1059 1750 1750
  cont1072 2577 2577
  </code></pre>
  <p>Print lines with different values in columns 2 and 3:</p>
  <pre><code>perl -lane 'print if <span class="math-container">$F[1] != $</span>F[2];' in.txt
  
  # Prints:
  cont100 1128 1125
  cont1006 103 19
  cont104 895 890
  cont1078 43 42
  cont1081 727 2
  </code></pre>
  <p>The Perl one-liner uses these command line flags:<br />
  <code>-e</code> : Tells Perl to look for code in-line, instead of in a file.<br />
  <code>-n</code> : Loop over the input one line at a time, assigning it to <code>$_</code> by default.<br />
  <code>-l</code> : Strip the input line separator (<code>&quot;\n&quot;</code> on *NIX by default) before executing the code in-line, and append it when printing.<br />
  <code>-a</code> : Split <code>$_</code> into array <code>@F</code> on whitespace or on the regex specified in <code>-F</code> option. Arrays in Perl are 0-indexed.</p>
  <p><strong>SEE ALSO:</strong><br />
  <a href="https://perldoc.perl.org/perlrun.html#Command-Switches" rel="nofollow noreferrer"><code>perldoc perlrun</code>: how to execute the Perl interpreter: command line switches</a></p>
   2108: <p>I think it is easy to do with awk, e.g. see <a href="https://stackoverflow.com/questions/42092693/awk-concise-way-to-check-if-2-fields-match-the-same-string">here</a>.</p>
  <p>For your example, with your data in <code>file</code>:</p>
  <pre><code>%  awk '<span class="math-container">$2 != $</span>3 {print $0}' file
  # outputs
  cont100 1128 1125
  cont1006 103 19
  cont104 895 890
  cont1078 43 42
  cont1081 727 2
  
  %  awk '<span class="math-container">$2 == $</span>3 {print $0}' file
  # outputs:
  cont1005 3642 3642
  cont1037 3146 3146
  cont1056 934 934
  cont1059 1750 1750
  cont1072 2577 2577
  
  </code></pre>
  <p>Note that where you say &quot;similar&quot; I am interpreting that to mean &quot;exactly the same&quot;, because that is the case in your example.</p>
  