<?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: sort &amp;amp; uniq in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688395#M794745</link>
    <description>Hi Ravinder,&lt;BR /&gt;sort -uo newfile queryusers &lt;BR /&gt;should be sufficent to remove dusplicates from queryusers if this file contains only the name of teh users otherwise is necessary to provide the key for the sort in teh format&lt;BR /&gt;-k to teh sort.&lt;BR /&gt;You can type man sort to look at this.&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
    <pubDate>Mon, 12 Dec 2005 04:15:36 GMT</pubDate>
    <dc:creator>Arturo Galbiati</dc:creator>
    <dc:date>2005-12-12T04:15:36Z</dc:date>
    <item>
      <title>sort &amp; uniq</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688392#M794742</link>
      <description>in a script I have the following:&lt;BR /&gt;&lt;BR /&gt;while read fakeuser&lt;BR /&gt;do&lt;BR /&gt;grep $fakeuser passgvts &amp;gt;&amp;gt; queryusers&lt;BR /&gt;done &amp;lt; testnotokusers&lt;BR /&gt;&lt;BR /&gt;However I have a lot of repeats in the file queryusers due to having two same entries in testnotokusers i.e. gillar and having two very similar entries in passgvts i.e. gillars &amp;amp; gillarst. Hence for each entry I end up with it being outputted to queryusers twice as it is being grepped twice i.e. the queryusers file may look like:&lt;BR /&gt;&lt;BR /&gt;gillars&lt;BR /&gt;gillarst&lt;BR /&gt;gillars&lt;BR /&gt;gillarts&lt;BR /&gt;&lt;BR /&gt;As there are hundreds of entries I can not go through the whole file deleting repetitions. It has been suggested that I do something like the following at the bottom of the script&lt;BR /&gt;&lt;BR /&gt;cat queryusers ¦ sort ¦ uniq &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;hence this would sort the queryusers file and send unique entries to the newfile. Can someone please tell me what options I need for "sort" and "uniq" if any. Thanks</description>
      <pubDate>Fri, 09 Dec 2005 09:40:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688392#M794742</guid>
      <dc:creator>Ravinder Singh Gill</dc:creator>
      <dc:date>2005-12-09T09:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: sort &amp; uniq</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688393#M794743</link>
      <description>If the queryusers file has the name as the first entry on the line, then |sort|uniq will reduce all occurances of the same name to just one. If the problem is that you are looking for an exact word (ie, gillar) and do not want anything else (like gillars and gillarst), use the -w option in grep. This option is only available with the latest patch for grep.</description>
      <pubDate>Fri, 09 Dec 2005 09:51:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688393#M794743</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-12-09T09:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: sort &amp; uniq</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688394#M794744</link>
      <description>&lt;BR /&gt;ah... a continuation/parallel thread to:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=980856" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=980856&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;As bill says... you may want to grep explicitly for a word, or use an egrep anchoring your words at begin of line, following them with whitepace, or anything else to make it do what you want exactly.&lt;BR /&gt;&lt;BR /&gt;Now if you do want to post-process that queryusers files, and not simply avoid the dups as per the other topic, then just can just tell uniq to look only for the first N characters:&lt;BR /&gt;&lt;BR /&gt;sort queryusers | uniq -w 6&lt;BR /&gt;&lt;BR /&gt;but then why not go one step further and jsut tell srot exatly what you want:&lt;BR /&gt;&lt;BR /&gt;Something like:&lt;BR /&gt;&lt;BR /&gt;sort -k 1.1,1.6 -u queryusers&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;caveat... I did not have access to an hpux box just now, so I only tested on my CD player which runs redhat linux 2.4&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 10 Dec 2005 14:21:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688394#M794744</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-12-10T14:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: sort &amp; uniq</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688395#M794745</link>
      <description>Hi Ravinder,&lt;BR /&gt;sort -uo newfile queryusers &lt;BR /&gt;should be sufficent to remove dusplicates from queryusers if this file contains only the name of teh users otherwise is necessary to provide the key for the sort in teh format&lt;BR /&gt;-k to teh sort.&lt;BR /&gt;You can type man sort to look at this.&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Mon, 12 Dec 2005 04:15:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-amp-uniq/m-p/3688395#M794745</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2005-12-12T04:15:36Z</dc:date>
    </item>
  </channel>
</rss>

