<?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: scripting question - 2 in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784816#M833635</link>
    <description>uniq only works on sorted files. If the uniqueness is to be dealt with accross the file, this perl command would do it&lt;BR /&gt;&lt;BR /&gt;# perl -ne '$x{$_}++;END{for$x(keys%x){$x{$x}==1&amp;amp;&amp;amp;print$x}' infile</description>
    <pubDate>Tue, 13 Aug 2002 07:09:20 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2002-08-13T07:09:20Z</dc:date>
    <item>
      <title>scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784810#M833629</link>
      <description>Hi experts,&lt;BR /&gt;              Im trying my best to make an awk program that could read a file and display only lines that are unique. The input file is a file with atleast 2000 lines some of the lines are the same. Could somebody help me on how to approach this?</description>
      <pubDate>Tue, 13 Aug 2002 06:25:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784810#M833629</guid>
      <dc:creator>Soji George_1</dc:creator>
      <dc:date>2002-08-13T06:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784811#M833630</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;I assume that you really want to do this with awk only? Could be a litte bit hard, I think.&lt;BR /&gt;&lt;BR /&gt;Couldn't you just pipe through uniq or sort -u before going to awk?&lt;BR /&gt;&lt;BR /&gt;Regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Tue, 13 Aug 2002 06:29:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784811#M833630</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2002-08-13T06:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784812#M833631</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Although I agree that this is probably best done with sort -u, if you want to confine it to awk you could use an array to store all the lines with $0 as the name of each element. That way, when awk goes to assign a value to the array element and that line had already been assigned, it will just be overwritten. You'll end up with unique lines.&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;   myarray[$0] = $0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;END {&lt;BR /&gt;   for ( line in myarray ) { print line )&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The difference will be that awk will return the lines in no particular order (it will not necisarily return them in the order it read them in).&lt;BR /&gt;&lt;BR /&gt;Simon.</description>
      <pubDate>Tue, 13 Aug 2002 06:46:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784812#M833631</guid>
      <dc:creator>Simon Abbott</dc:creator>
      <dc:date>2002-08-13T06:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784813#M833632</link>
      <description>Oops! that should have been a } after print line...&lt;BR /&gt;&lt;BR /&gt;{ &lt;BR /&gt;myarray[$0] = $0 &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;END { &lt;BR /&gt;for ( line in myarray ) { print line }&lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Aug 2002 06:48:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784813#M833632</guid>
      <dc:creator>Simon Abbott</dc:creator>
      <dc:date>2002-08-13T06:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784814#M833633</link>
      <description>Hi&lt;BR /&gt;Perhaps you should look at the command "uniq" (man uniq).</description>
      <pubDate>Tue, 13 Aug 2002 06:49:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784814#M833633</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-08-13T06:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784815#M833634</link>
      <description>Why not try the standard command 'uniq -u' : Print those lines that are NOT repeated in the original file.&lt;BR /&gt;&lt;BR /&gt;Ofcourse it only compares adjacent lines...&lt;BR /&gt;You might wanna compare this with the other solutions like sort -u.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan</description>
      <pubDate>Tue, 13 Aug 2002 06:53:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784815#M833634</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-08-13T06:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784816#M833635</link>
      <description>uniq only works on sorted files. If the uniqueness is to be dealt with accross the file, this perl command would do it&lt;BR /&gt;&lt;BR /&gt;# perl -ne '$x{$_}++;END{for$x(keys%x){$x{$x}==1&amp;amp;&amp;amp;print$x}' infile</description>
      <pubDate>Tue, 13 Aug 2002 07:09:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784816#M833635</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-08-13T07:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784817#M833636</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If you want to retain the original order, try&lt;BR /&gt; perl -ne 'push@a,$_;$h{$_}++;END{foreach(@a)print unless$h{$_}&amp;gt;1}}' infile&lt;BR /&gt;&lt;BR /&gt;or in awkese&lt;BR /&gt;&lt;BR /&gt; awk '{a[NR]=$0;h[$0]++;}END{for(i=1;i&amp;lt;=NR;i++){if(h[a[i]]==1)print a[i]}}'infile&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;  JW.</description>
      <pubDate>Thu, 15 Aug 2002 03:01:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784817#M833636</guid>
      <dc:creator>John Wright_1</dc:creator>
      <dc:date>2002-08-15T03:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question - 2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784818#M833637</link>
      <description>or even...&lt;BR /&gt;&lt;BR /&gt;awk '{a[$0]++}END{for(l in a){if(a[l]==1){print l}}}' filename&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
      <pubDate>Thu, 15 Aug 2002 06:25:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question-2/m-p/2784818#M833637</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-08-15T06:25:48Z</dc:date>
    </item>
  </channel>
</rss>

