<?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: Distinct lines from FileA in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053000#M745839</link>
    <description>Yes, you need to sort the files beforehand.  Hence these following lines in my script above:&lt;BR /&gt;&lt;BR /&gt;sort ${F1} &amp;gt; ${F1S}&lt;BR /&gt;sort ${F2} &amp;gt; ${F2S}&lt;BR /&gt;&lt;BR /&gt;Also, in this scenario, 'nl' is going to number the lines of output piped from the 'comm' command--not the position of lines unique to fileA.  I suggest using the script I supplied.</description>
    <pubDate>Thu, 14 Jun 2007 11:23:44 GMT</pubDate>
    <dc:creator>spex</dc:creator>
    <dc:date>2007-06-14T11:23:44Z</dc:date>
    <item>
      <title>Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052992#M745831</link>
      <description>I have got 2 files having thousands of line in each. I would like to find out ONLY lines not available in 2nd file.&lt;BR /&gt;May be something like&lt;BR /&gt;lines=`ec -l fileA`;&lt;BR /&gt;i=1&lt;BR /&gt;while [ $i -le $lines ]&lt;BR /&gt;do&lt;BR /&gt;if line$i NOTfound in fileB then &amp;gt;&amp;gt; NOTPRESENT.txt&lt;BR /&gt;i=i+1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Please suggest!!!</description>
      <pubDate>Thu, 14 Jun 2007 09:29:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052992#M745831</guid>
      <dc:creator>panchpan</dc:creator>
      <dc:date>2007-06-14T09:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052993#M745832</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Use 'comm'.  See the manpages (and examples therein) for 'comm(1)'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 14 Jun 2007 09:35:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052993#M745832</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-06-14T09:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052994#M745833</link>
      <description>Thank you - I will try this.&lt;BR /&gt;Also, please advice how can i get the output printed with line numbers?</description>
      <pubDate>Thu, 14 Jun 2007 09:50:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052994#M745833</guid>
      <dc:creator>panchpan</dc:creator>
      <dc:date>2007-06-14T09:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052995#M745834</link>
      <description>Below command will print numbered lines that are found in fileA but not in fileB.&lt;BR /&gt;&lt;BR /&gt;# comm -23 fileA fileB | nl -nln -s' '</description>
      <pubDate>Thu, 14 Jun 2007 10:11:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052995#M745834</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-06-14T10:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052996#M745835</link>
      <description>#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;F1=A&lt;BR /&gt;F1S=A.sorted&lt;BR /&gt;F2=B&lt;BR /&gt;F2S=B.sorted&lt;BR /&gt;F1U=A.unique&lt;BR /&gt;&lt;BR /&gt;sort ${F1} &amp;gt; ${F1S}&lt;BR /&gt;sort ${F2} &amp;gt; ${F2S}&lt;BR /&gt;comm -23 ${F1S} ${F2S} &amp;gt; ${F1U}&lt;BR /&gt;grep -F -n -f ${F1U} ${F1}&lt;BR /&gt;&lt;BR /&gt;rm -f ${F1S} ${F2S} ${F1U}&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Jun 2007 10:19:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052996#M745835</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2007-06-14T10:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052997#M745836</link>
      <description>for serv_cnt in `cat /home/mfgeb/pp/serv.txt`&lt;BR /&gt;do&lt;BR /&gt;j=$serv_cnt&lt;BR /&gt;echo "===[ Directory List for Server: $serv_cnt ]==="&lt;BR /&gt;ssh $serv_cnt "find /mfgdata/ -type d -exec ls -ld {} \; 2&amp;gt;/dev/null "&lt;BR /&gt;done &amp;gt;&amp;gt; $j.mfgdata-ux-dir.ls&lt;BR /&gt;&lt;BR /&gt;How can I dynamically generated output file with differnt names???</description>
      <pubDate>Thu, 14 Jun 2007 10:19:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052997#M745836</guid>
      <dc:creator>panchpan</dc:creator>
      <dc:date>2007-06-14T10:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052998#M745837</link>
      <description>I suggest expounding upon your question in a new thread.</description>
      <pubDate>Thu, 14 Jun 2007 10:25:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052998#M745837</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2007-06-14T10:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052999#M745838</link>
      <description>Hello.&lt;BR /&gt;I ran below command:&lt;BR /&gt;&lt;BR /&gt;comm -23 data-ux-9th.lst data-lx-9th.lst | nl -nln -s' ' &amp;gt; not-in-lx-data.lst&lt;BR /&gt;&lt;BR /&gt;found that output file still has below entries:&lt;BR /&gt;&lt;BR /&gt;data/amfp2p/log/api/IPCSH&lt;BR /&gt;data/amfp2p/log/scm&lt;BR /&gt;data/amfp2p/log/audit&lt;BR /&gt;data/amfp2p/log/ecgei&lt;BR /&gt;&lt;BR /&gt;Though, these were present in both files. Do i need to sort files beforehand. Please suggest how can i run comm command?</description>
      <pubDate>Thu, 14 Jun 2007 11:11:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5052999#M745838</guid>
      <dc:creator>panchpan</dc:creator>
      <dc:date>2007-06-14T11:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053000#M745839</link>
      <description>Yes, you need to sort the files beforehand.  Hence these following lines in my script above:&lt;BR /&gt;&lt;BR /&gt;sort ${F1} &amp;gt; ${F1S}&lt;BR /&gt;sort ${F2} &amp;gt; ${F2S}&lt;BR /&gt;&lt;BR /&gt;Also, in this scenario, 'nl' is going to number the lines of output piped from the 'comm' command--not the position of lines unique to fileA.  I suggest using the script I supplied.</description>
      <pubDate>Thu, 14 Jun 2007 11:23:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053000#M745839</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2007-06-14T11:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053001#M745840</link>
      <description>If have a little perl scipt handy which does roughly what you desire. It takes two file names as argument and compares them. The files doal NOT have to be sorted. The first file will be stored in memory as keys to an accosiative array, the values being the line numbers. This obviously does NOT handle duplicate lines (SMOP to make it do that :-), and it might run into memory problems with large (many MB) input files. 10,000 lines should be fine. 1,000,000 probably not.&lt;BR /&gt;&lt;BR /&gt;Try it?&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;---- compare_file_lines.pl ----------&lt;BR /&gt;#&lt;BR /&gt;# Open first file and remember all lines with their line numbers in array f1&lt;BR /&gt;#&lt;BR /&gt;$name = shift @ARGV or die "Must provide first filename";&lt;BR /&gt;open FILE, "&amp;lt;$name" or die "Could not read file $name";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;   chomp;&lt;BR /&gt;   next if /^$/;     # skip blanks&lt;BR /&gt;   next if /^\s+#/;  # skip comments&lt;BR /&gt;   $f1{$_}=$.;&lt;BR /&gt;}&lt;BR /&gt;close FILE;          # reset line number&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# open and loop through second file.&lt;BR /&gt;# delete each corresponding element from the array&lt;BR /&gt;# Report if missing (could be duplicate in second file)&lt;BR /&gt;#&lt;BR /&gt;$name = shift @ARGV or die "Must provide second filename";&lt;BR /&gt;open FILE, "&amp;lt;$name" or die "Could not read file $name";&lt;BR /&gt;while (&lt;FILE&gt;) {&lt;BR /&gt;   chomp;&lt;BR /&gt;   next if /^$/;     # skip blanks&lt;BR /&gt;   next if /^\s+#/;  # skip comments&lt;BR /&gt;   next if delete $f1{$_};&lt;BR /&gt;   print "2:$. not in 1:$_\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# All lines remaining in array must not have been in second file&lt;BR /&gt;#&lt;BR /&gt;foreach (sort {$f1{$a} &amp;lt;=&amp;gt; $f1{$b}} keys %f1) {&lt;BR /&gt;   print "1:$f1{$_} not in 2:$_\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;-------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# perl compare_file_lines.pl left right&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;/FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Thu, 14 Jun 2007 12:03:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053001#M745840</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-06-14T12:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053002#M745841</link>
      <description>As already mentioned you need to sort(1) files before putting them thru comm(1). See the comm(1) man page for details. I assumed that fileA and fileB were sorted. Here's a script you can use for what you are trying to do...hope it helps:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;sort fileA &amp;gt; fileA.srtd&lt;BR /&gt;sort fileB &amp;gt; fileB.srtd&lt;BR /&gt;comm -23 fileA.srtd fileB.srtd | nl -nln -s' '</description>
      <pubDate>Thu, 14 Jun 2007 12:49:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053002#M745841</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-06-14T12:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053003#M745842</link>
      <description>&amp;gt;please advice how can i get the output printed with line numbers?&lt;BR /&gt;&lt;BR /&gt;Line numbers starting from 1?  Or starting from the original file1?&lt;BR /&gt;&lt;BR /&gt;Sandman did the first. spex did the latter but his fgrep -n -f will kill you on performance if the number of records is large.&lt;BR /&gt;&lt;BR /&gt;If you really want to do this, you need to number each file with nl and a ID, then sort, then use awk to look for lines only in first file.&lt;BR /&gt;&lt;BR /&gt;Let me know if you are interested.</description>
      <pubDate>Fri, 15 Jun 2007 02:05:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053003#M745842</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-15T02:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct lines from FileA</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053004#M745843</link>
      <description>BIG THANKS !!!</description>
      <pubDate>Fri, 15 Jun 2007 06:19:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/distinct-lines-from-filea/m-p/5053004#M745843</guid>
      <dc:creator>panchpan</dc:creator>
      <dc:date>2007-06-15T06:19:03Z</dc:date>
    </item>
  </channel>
</rss>

