<?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 with -u unique option in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993127#M778827</link>
    <description>I tried with sort -k 1,1 -u and works.</description>
    <pubDate>Tue, 25 Jul 2006 16:47:57 GMT</pubDate>
    <dc:creator>Ivan Ferreira</dc:creator>
    <dc:date>2006-07-25T16:47:57Z</dc:date>
    <item>
      <title>sort with -u unique option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993125#M778825</link>
      <description>&lt;!--!*#--&gt;I have been looking at this for an hour now and cannot see what I am doing wrong.  I use the following commands to extract four fields from all of our various passwd files, and I only want one line returned for each logonid:&lt;BR /&gt;&lt;BR /&gt;cat $secdir/*.passwd | awk -F: '{print $1,$3,$4,$5}' &lt;BR /&gt;&lt;BR /&gt;Here is an example of the raw data for one logonid:&lt;BR /&gt;&lt;BR /&gt;cat $secdir/*.passwd | awk -F: '{print $1,$3,$4,$5}' | sort|grep best1&lt;BR /&gt;best1 1100 1100 best1&lt;BR /&gt;best1 1100 1100 best1&lt;BR /&gt;best1 1100 1100 best1&lt;BR /&gt;best1 1100 1100 best1&lt;BR /&gt;best1 1100 1100 best1&lt;BR /&gt;best1 1100 1100 best1&lt;BR /&gt;best1 1500 550 Application ID,PDC,,&lt;BR /&gt;best1 1500 550 Best1,,,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When I run the following command:&lt;BR /&gt;&lt;BR /&gt;cat $secdir/*.passwd | awk -F: '{print $1,$3,$4,$5}' | sort -u -k1&lt;BR /&gt;&lt;BR /&gt;I would expect to get only one line back (if I understand the -u option correctly from the man page).  But instead I get:&lt;BR /&gt;&lt;BR /&gt;best1 1100 1100 best1&lt;BR /&gt;best1 1500 550 Application ID,PDC,,&lt;BR /&gt;best1 1500 550 Best1,,,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It's as if the -u was being applied to the entire line, rather than just the first key field.&lt;BR /&gt;&lt;BR /&gt;Here is the section of the man page for sort I am relying on:&lt;BR /&gt;&lt;BR /&gt;        -u          Unique: suppress all but one in each set of lines&lt;BR /&gt;                       having equal keys.&lt;BR /&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Tue, 25 Jul 2006 16:41:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993125#M778825</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2006-07-25T16:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: sort with -u unique option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993126#M778826</link>
      <description>If you just want the unique login id's, why do you need the other 4 fields?&lt;BR /&gt;&lt;BR /&gt;Why not just do:&lt;BR /&gt;&lt;BR /&gt;cat $secdir/*.passwd | awk -F: '{print $1}' | sort -u&lt;BR /&gt;&lt;BR /&gt;I don't really see what you are gaining, or trying for, by including the other information.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Jul 2006 16:46:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993126#M778826</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-07-25T16:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: sort with -u unique option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993127#M778827</link>
      <description>I tried with sort -k 1,1 -u and works.</description>
      <pubDate>Tue, 25 Jul 2006 16:47:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993127#M778827</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2006-07-25T16:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: sort with -u unique option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993128#M778828</link>
      <description>Patrick -&lt;BR /&gt;&lt;BR /&gt;I need the other four fields (UID, GID, etc) for the report that is eventually generated, but only one line per logonid.&lt;BR /&gt;&lt;BR /&gt;Scott</description>
      <pubDate>Tue, 25 Jul 2006 16:49:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993128#M778828</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2006-07-25T16:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: sort with -u unique option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993129#M778829</link>
      <description>Ivan -&lt;BR /&gt;&lt;BR /&gt;sort -k1,1 was all that was needed!  &lt;BR /&gt;&lt;BR /&gt;I 'assumed' wrong that 'sort -k1' only sorted on the first key.  In reality (from the sort man page):&lt;BR /&gt;&lt;BR /&gt;"A missing field_end means the end of the   line."&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Scott</description>
      <pubDate>Tue, 25 Jul 2006 16:53:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993129#M778829</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2006-07-25T16:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: sort with -u unique option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993130#M778830</link>
      <description>Hi Scott:&lt;BR /&gt;&lt;BR /&gt;Yes, your specification for the sort key is actually until the end-of-line.&lt;BR /&gt;&lt;BR /&gt;This is a common mistake.  You need to specify both the start and the end of the key:&lt;BR /&gt;&lt;BR /&gt;# sort -u -k1,1&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 25 Jul 2006 16:53:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993130#M778830</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-25T16:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: sort with -u unique option</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993131#M778831</link>
      <description>sort -k1,1 was all that was needed!</description>
      <pubDate>Tue, 25 Jul 2006 16:54:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sort-with-u-unique-option/m-p/4993131#M778831</guid>
      <dc:creator>Scott Lindstrom_2</dc:creator>
      <dc:date>2006-07-25T16:54:20Z</dc:date>
    </item>
  </channel>
</rss>

