<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: command or script for equal lines in files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171012#M793940</link>
    <description>If grep wildcards like that exist, you could extent the sed line to escape them ('s|\([.*+?]\)|\[\1\]|g').</description>
    <pubDate>Thu, 22 Jan 2004 09:41:05 GMT</pubDate>
    <dc:creator>Elmar P. Kolkman</dc:creator>
    <dc:date>2004-01-22T09:41:05Z</dc:date>
    <item>
      <title>command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171003#M793931</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I need a HP-UX command or simple script that outputs the lines that are occuring in two textfiles (like the opposite of the diff command).&lt;BR /&gt;&lt;BR /&gt;Example :&lt;BR /&gt;File A contains&lt;BR /&gt; Abc&lt;BR /&gt; Acc&lt;BR /&gt; Bcc&lt;BR /&gt;&lt;BR /&gt;Fil B contains&lt;BR /&gt; Acc&lt;BR /&gt; Acdc&lt;BR /&gt; Bcc&lt;BR /&gt; Bde&lt;BR /&gt;&lt;BR /&gt;The desired output would be :&lt;BR /&gt; Acc&lt;BR /&gt; Bcc&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;Franky&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Jan 2004 08:57:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171003#M793931</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2004-01-22T08:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171004#M793932</link>
      <description>There probably is a command to do this but something like&lt;BR /&gt;&lt;BR /&gt;while read $line&lt;BR /&gt;do&lt;BR /&gt;  grep $line file2&lt;BR /&gt;done &amp;lt; file1&lt;BR /&gt; &lt;BR /&gt;AQ bit slow for big files though so maybe awk or perl is what you need.</description>
      <pubDate>Thu, 22 Jan 2004 09:02:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171004#M793932</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-01-22T09:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171005#M793933</link>
      <description>Franky,&lt;BR /&gt;&lt;BR /&gt;Try "man 1 comm".&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 22 Jan 2004 09:03:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171005#M793933</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2004-01-22T09:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171006#M793934</link>
      <description>Specifically, I think you want&lt;BR /&gt;&lt;BR /&gt;"comm -3 FileA FileB"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 22 Jan 2004 09:04:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171006#M793934</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2004-01-22T09:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171007#M793935</link>
      <description>easy:&lt;BR /&gt;&lt;BR /&gt;comm -12 fileA fileB&lt;BR /&gt;&lt;BR /&gt;but files have to be sorted&lt;BR /&gt;&lt;BR /&gt;if not&lt;BR /&gt;&lt;BR /&gt;perl -e'$f=pop;%l=map{$_=&amp;gt;1}&amp;lt;&amp;gt;;@ARGV=($f);for(&amp;lt;&amp;gt;){exists$l{$_}and print}' fileA fileB&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 22 Jan 2004 09:05:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171007#M793935</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-01-22T09:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171008#M793936</link>
      <description>Wow,&lt;BR /&gt;&lt;BR /&gt;Thanks for these replies coming so fast.&lt;BR /&gt;&lt;BR /&gt;I only knew of the cmp and diff command, but indeed comm -12 does the job.&lt;BR /&gt;&lt;BR /&gt;Thanks,Franky</description>
      <pubDate>Thu, 22 Jan 2004 09:10:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171008#M793936</guid>
      <dc:creator>Franky Leeuwerck_1</dc:creator>
      <dc:date>2004-01-22T09:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171009#M793937</link>
      <description>Provided you two files are sorted (they are in your example) you can use the comm command.&lt;BR /&gt;&lt;BR /&gt;comm -12 A B&lt;BR /&gt;&lt;BR /&gt;gives you the required output.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Thu, 22 Jan 2004 09:10:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171009#M793937</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2004-01-22T09:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171010#M793938</link>
      <description>Or:&lt;BR /&gt;sed -e 's|^|^|' -e 's|$|$|' fileA &amp;gt;fileA.tmp&lt;BR /&gt;grep -f fileA.tmp filB&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Jan 2004 09:23:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171010#M793938</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-22T09:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171011#M793939</link>
      <description>elmar, that is fun! what if file a has a line&lt;BR /&gt;&lt;BR /&gt;.*&lt;BR /&gt;&lt;BR /&gt;? :) :)&lt;BR /&gt;&lt;BR /&gt;you could do that with GNU grep&lt;BR /&gt;&lt;BR /&gt;# gnu-fgrep -x -f fileA fileB&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 22 Jan 2004 09:27:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171011#M793939</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-01-22T09:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171012#M793940</link>
      <description>If grep wildcards like that exist, you could extent the sed line to escape them ('s|\([.*+?]\)|\[\1\]|g').</description>
      <pubDate>Thu, 22 Jan 2004 09:41:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171012#M793940</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-22T09:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171013#M793941</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I like the funny Elmar's one ... It should work even with lines like .* if he uses 'grep -Fx' :^)&lt;BR /&gt;&lt;BR /&gt;Regards.</description>
      <pubDate>Thu, 22 Jan 2004 11:01:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171013#M793941</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2004-01-22T11:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171014#M793942</link>
      <description>Jean-Louis, it was something I tried, but it doesn't work, since not only the . and * are not interpreted, but the ^ and $ too, meaning that begin-of-line and end-of-line are not interpreted. And you need them to prevent lines like 'abcd' to show up if you have 'bcd' in the other file...&lt;BR /&gt;With the capitals in the example it should work better (start of line is forced with the capital) but if Accccdefed was in filB, it would show up...</description>
      <pubDate>Fri, 23 Jan 2004 00:55:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171014#M793942</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-23T00:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171015#M793943</link>
      <description>Elmar,&lt;BR /&gt;&lt;BR /&gt;I meant that I liked your grep -f tip. But with -Fx you don't even need the sed and the temporary file :&lt;BR /&gt;&lt;BR /&gt;-x for exact lines (so no sed needed for ^ and $)&lt;BR /&gt;&lt;BR /&gt;-F for fixed strings (prevent from lines containing .*)&lt;BR /&gt;&lt;BR /&gt;So the answer could simply be :&lt;BR /&gt;&lt;BR /&gt;grep -Fxf fileA fileB&lt;BR /&gt;&lt;BR /&gt;which gives the same result as :&lt;BR /&gt;&lt;BR /&gt;comm -12 fileA fileB&lt;BR /&gt;&lt;BR /&gt;In fact in this case there is even no need to work on sorted files which is easier.&lt;BR /&gt;&lt;BR /&gt;Regards.&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Jan 2004 05:25:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171015#M793943</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2004-01-23T05:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171016#M793944</link>
      <description>but comm is cut for the job. Look at the following benchmark, assumed that the files _are_ sorted:&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 166 &amp;gt; perl -le'print chr(65+int rand 26),map{chr(97+int rand 26)}1..5 for 1..50000' | sort &amp;gt; x0&lt;BR /&gt;lt09:/tmp 167 &amp;gt; perl -le'print chr(65+int rand 26),map{chr(97+int rand 26)}1..5 for 1..50000' | sort &amp;gt; x1&lt;BR /&gt;lt09:/tmp 168 &amp;gt; time comm -12 x0 x1 &amp;gt; x01.0&lt;BR /&gt;0.020u 0.000s 0:00.00 0.0%      0+0k 0+0io 123pf+0w&lt;BR /&gt;lt09:/tmp 169 &amp;gt; time grep -Fxf x0 x1 &amp;gt; x01.1&lt;BR /&gt;0.300u 0.020s 0:00.31 103.2%    0+0k 0+0io 136pf+0w&lt;BR /&gt;lt09:/tmp 170 &amp;gt; perl -le'print chr(65+int rand 26),map{chr(97+int rand 26)}1..5 for 1..500000' | sort &amp;gt; x0&lt;BR /&gt;lt09:/tmp 171 &amp;gt; perl -le'print chr(65+int rand 26),map{chr(97+int rand 26)}1..5 for 1..500000' | sort &amp;gt; x1&lt;BR /&gt;lt09:/tmp 172 &amp;gt; time comm -12 x0 x1 &amp;gt; x01.0&lt;BR /&gt;0.150u 0.010s 0:00.08 200.0%    0+0k 0+0io 123pf+0w&lt;BR /&gt;lt09:/tmp 173 &amp;gt; time grep -Fxf x0 x1 &amp;gt; x01.1&lt;BR /&gt;4.230u 0.060s 0:04.32 99.3%     0+0k 0+0io 136pf+0w&lt;BR /&gt;lt09:/tmp 174 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;this was on linux, where GNU grep is the default, but HP-UX will show similar results&lt;BR /&gt;&lt;BR /&gt;So *IF* you would decide to go for fgrep (equal to grep -F), be sure to put the smallest file in front&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sat, 24 Jan 2004 12:46:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171016#M793944</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-01-24T12:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171017#M793945</link>
      <description>Ohh, and one more thing.&lt;BR /&gt;&lt;BR /&gt;the commands are not the same, and with the fgrep command the output might differ if the files are swapped. This is because handling of double lines is different in comm and grep.&lt;BR /&gt;watch this, from the last example:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;lt09:/tmp 178 &amp;gt; ll x[01]*&lt;BR /&gt; 246644 -rw-rw-rw-    1 merijn   users     3500000 2004-01-24 18:42 x0&lt;BR /&gt; 246692 -rw-rw-rw-    1 merijn   users        5544 2004-01-24 18:42 x01.0&lt;BR /&gt; 246693 -rw-rw-rw-    1 merijn   users        5551 2004-01-24 18:42 x01.1&lt;BR /&gt; 246691 -rw-rw-rw-    1 merijn   users     3500000 2004-01-24 18:42 x1&lt;BR /&gt;lt09:/tmp 179 &amp;gt; diff x01*&lt;BR /&gt;444a445&lt;BR /&gt;&amp;gt; Pgpcds&lt;BR /&gt;Exit 1&lt;BR /&gt;lt09:/tmp 180 &amp;gt; grep Pgpcds x[01]*&lt;BR /&gt;x0:Pgpcds&lt;BR /&gt;x01.0:Pgpcds&lt;BR /&gt;x01.1:Pgpcds&lt;BR /&gt;x01.1:Pgpcds&lt;BR /&gt;x1:Pgpcds&lt;BR /&gt;x1:Pgpcds&lt;BR /&gt;lt09:/tmp 181 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sat, 24 Jan 2004 12:59:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171017#M793945</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-01-24T12:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: command or script for equal lines in files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171018#M793946</link>
      <description>Same problem discussed in &lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=403456" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=403456&lt;/A&gt;&lt;BR /&gt;(FYI only)&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 28 Jan 2004 15:41:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/command-or-script-for-equal-lines-in-files/m-p/3171018#M793946</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-01-28T15:41:51Z</dc:date>
    </item>
  </channel>
</rss>

