<?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: Eliminating Dups in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074488#M92140</link>
    <description>Have a look at the man page for the uniq command. &lt;BR /&gt;&lt;BR /&gt;uniq myfile should do what you want.&lt;BR /&gt;</description>
    <pubDate>Tue, 16 Oct 2007 11:55:50 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2007-10-16T11:55:50Z</dc:date>
    <item>
      <title>Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074487#M92139</link>
      <description>Hi all&lt;BR /&gt;HPUX 11x PARISC system.&lt;BR /&gt;&lt;BR /&gt;I have a file that looks like this&lt;BR /&gt;John,Doe&lt;BR /&gt;John,Doe&lt;BR /&gt;John,Doe&lt;BR /&gt;Mary,Poppin&lt;BR /&gt;Mary,Poppin&lt;BR /&gt;Mary,Poppin&lt;BR /&gt;&lt;BR /&gt;I'm writing a script in perl and I would like to know if anyone knows a method to get rid of duplicate lines.&lt;BR /&gt;&lt;BR /&gt;thanks in advance for any help/suggestions.</description>
      <pubDate>Tue, 16 Oct 2007 11:40:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074487#M92139</guid>
      <dc:creator>David Bellamy</dc:creator>
      <dc:date>2007-10-16T11:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074488#M92140</link>
      <description>Have a look at the man page for the uniq command. &lt;BR /&gt;&lt;BR /&gt;uniq myfile should do what you want.&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Oct 2007 11:55:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074488#M92140</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-10-16T11:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074489#M92141</link>
      <description>David,&lt;BR /&gt;&lt;BR /&gt;Does it need to be perl? COs the sort and uniq commands will take care of this very easily:&lt;BR /&gt;&lt;BR /&gt;sort &lt;FILE&gt; | uniq&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;/FILE&gt;</description>
      <pubDate>Tue, 16 Oct 2007 11:57:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074489#M92141</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2007-10-16T11:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074490#M92142</link>
      <description>&lt;!--!*#--&gt;Hi David:&lt;BR /&gt;&lt;BR /&gt;In Perl, use a hash to collect the unique items.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my %things;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    $things{$_}++;&lt;BR /&gt;}&lt;BR /&gt;for my $key (sort keys %things) {&lt;BR /&gt;    print "$key\n";&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 16 Oct 2007 12:05:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074490#M92142</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-10-16T12:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074491#M92143</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;sort -u&lt;BR /&gt;&lt;BR /&gt;grep ^$ (to get rid of blank lines.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 16 Oct 2007 12:05:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074491#M92143</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2007-10-16T12:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074492#M92144</link>
      <description>&lt;!--!*#--&gt;Simply populate a hash.&lt;BR /&gt;One possible way:&lt;BR /&gt;&lt;BR /&gt;map {chomp;$seen{$_}++ unless exists $seen{$_}} &lt;DATA&gt;;&lt;BR /&gt;@singles = keys %seen;&lt;BR /&gt;__DATA__&lt;BR /&gt;John,Doe&lt;BR /&gt;John,Doe&lt;BR /&gt;John,Doe&lt;BR /&gt;Mary,Poppin&lt;BR /&gt;Mary,Poppin&lt;BR /&gt;Mary,Poppin&lt;BR /&gt;&lt;/DATA&gt;</description>
      <pubDate>Tue, 16 Oct 2007 12:13:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074492#M92144</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-10-16T12:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074493#M92145</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;generally its easy when your input is sorted.&lt;BR /&gt;The command&lt;BR /&gt;uniq filename&lt;BR /&gt;&lt;BR /&gt;will output only different lines.&lt;BR /&gt;&lt;BR /&gt;In perl, remember the last valid line and skip identical ones:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;my $last;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    if ($last eq $_) { next; }&lt;BR /&gt;    $last = $_;&lt;BR /&gt;    print $_;&lt;BR /&gt;}&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Change the print statement by your code.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 16 Oct 2007 12:14:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074493#M92145</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-10-16T12:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074494#M92146</link>
      <description>Oops, sorry for this dup.&lt;BR /&gt;Use James' solution...</description>
      <pubDate>Tue, 16 Oct 2007 12:15:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074494#M92146</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-10-16T12:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074495#M92147</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;And printing them as they come, skipping dups could look like:&lt;BR /&gt;&lt;BR /&gt;$ perl -ne 'print unless $x{$_}++' &lt;FILE&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;/FILE&gt;</description>
      <pubDate>Tue, 16 Oct 2007 12:24:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074495#M92147</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-10-16T12:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074496#M92148</link>
      <description>&lt;!--!*#--&gt;... and here's a rather fully fleshed out version of an all Perl solution although it would make as much sense to run your file through the uniq command inside Perl.&lt;BR /&gt;&lt;BR /&gt;------------------------------------&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use English;&lt;BR /&gt;use constant TRUE =&amp;gt; 1;&lt;BR /&gt;&lt;BR /&gt;my %exists = ();&lt;BR /&gt;my @uniqs = ();&lt;BR /&gt;my $stat = 0;&lt;BR /&gt;my $fname = "myfile";&lt;BR /&gt;&lt;BR /&gt;my $cc = open(FH,$fname);&lt;BR /&gt;if (defined($cc))&lt;BR /&gt;  {&lt;BR /&gt;    my $s = '';&lt;BR /&gt;    while (defined($s = &lt;FH&gt;))&lt;BR /&gt;      {&lt;BR /&gt;        chomp($s);&lt;BR /&gt; unless ($exists{$s})&lt;BR /&gt;   {  &lt;BR /&gt;     $exists{$s} = TRUE;&lt;BR /&gt;     push(@uniqs,$s);&lt;BR /&gt;          }&lt;BR /&gt;      }&lt;BR /&gt;    close(FH);&lt;BR /&gt;    my $i = 0;&lt;BR /&gt;    while ($i &amp;lt;= $#uniqs)&lt;BR /&gt;      {&lt;BR /&gt;        print $uniqs[$i],"\n";&lt;BR /&gt; ++$i;&lt;BR /&gt;      }&lt;BR /&gt;  }&lt;BR /&gt;else&lt;BR /&gt;  {&lt;BR /&gt;    $stat = $ERRNO;&lt;BR /&gt;    printf ("Can't open %s status %d\n",$fname,$stat);&lt;BR /&gt;  }&lt;BR /&gt;exit($stat);&lt;BR /&gt;---------------------------------------&lt;BR /&gt;&lt;BR /&gt;as the previous examples do, it uses a hash to keep up with the data that has already been read and only if the entry is the first encounter does it add to the output array.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/FH&gt;</description>
      <pubDate>Tue, 16 Oct 2007 12:28:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074496#M92148</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-10-16T12:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074497#M92149</link>
      <description>Thanks to all, James your solution was perfect.</description>
      <pubDate>Tue, 16 Oct 2007 12:35:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074497#M92149</guid>
      <dc:creator>David Bellamy</dc:creator>
      <dc:date>2007-10-16T12:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminating Dups</title>
      <link>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074498#M92150</link>
      <description>Once again thanks to all</description>
      <pubDate>Tue, 16 Oct 2007 12:36:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/eliminating-dups/m-p/5074498#M92150</guid>
      <dc:creator>David Bellamy</dc:creator>
      <dc:date>2007-10-16T12:36:10Z</dc:date>
    </item>
  </channel>
</rss>

