<?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: Best and fast way to sort cXtYdZ values picking the lowest &amp;quot;c&amp;quot; value? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726305#M100908</link>
    <description>&lt;BR /&gt;Didn't my example give you enough hints to get going?&lt;BR /&gt;&lt;BR /&gt;If you just want the device list then here is a minor adaption to that...&lt;BR /&gt;&lt;BR /&gt;--------------&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  if (/c(\d+)t(\d+)d(\d+)\s/) {&lt;BR /&gt;    $num = ($1*1000 +$2)*1000+$3;&lt;BR /&gt;    $dsk{$num} = "c$1t$2d$3";&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;for $key (sort {$a &amp;lt;=&amp;gt; $b} keys %dsk) {&lt;BR /&gt;   print $dsk{$key}."\n";&lt;BR /&gt;   }&lt;BR /&gt;--------------------&lt;BR /&gt;&lt;BR /&gt;fyi...  The {$a &amp;lt;=&amp;gt; $} is a localy defined sort function using a numeric compare instead of the default string compare.&lt;BR /&gt;Due to the way i contractured the artifical 'key', either should work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;------------&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  if (/c(\d+)t(\d+)d(\d+)\s/) {&lt;BR /&gt;    $num = ($1*1000 +$2)*1000+$3;&lt;BR /&gt;    $dsk{$num} = "c$1t$2d$3";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;for $key (sort keys %dsk) {&lt;BR /&gt;   print $dsk{$key}."\n";&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 07 Feb 2006 14:02:41 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2006-02-07T14:02:41Z</dc:date>
    <item>
      <title>Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726295#M100898</link>
      <description>I'm dealing with hundreds/thousands of cXtYdZ values on a typical server and I have a need in my script to pick from a list of cXtYdZ the lowest numbered cX, then the lowest numbers tY then the lowest numbered dZ -- in effect the lowest numbered/valued cXtYdZ.&lt;BR /&gt;&lt;BR /&gt;Suggestions? More points to Perl constructs.&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Feb 2006 12:18:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726295#M100898</guid>
      <dc:creator>Alzhy</dc:creator>
      <dc:date>2006-02-07T12:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726296#M100899</link>
      <description>Shalom Nelson,&lt;BR /&gt;&lt;BR /&gt;Perl from someone else&lt;BR /&gt;&lt;BR /&gt;ls | /dev/dsk/c* | sort -rn &lt;BR /&gt;&lt;BR /&gt;take out the r if it comes out backwards.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 07 Feb 2006 12:21:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726296#M100899</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-02-07T12:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726297#M100900</link>
      <description>perl or no perl, you still run it through the 'sort' command&lt;BR /&gt;&lt;BR /&gt;In perl, make a call to a system command&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Feb 2006 12:30:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726297#M100900</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2006-02-07T12:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726298#M100901</link>
      <description>ioscan -funC disk | grep c | grep -v Class | awk '{ print }'&lt;BR /&gt;&lt;BR /&gt;Does this output not sorted.&lt;BR /&gt;If i understood the question the output of the command above is what you are expecting.&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Tue, 07 Feb 2006 12:32:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726298#M100901</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2006-02-07T12:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726299#M100902</link>
      <description>sorry typo. it's like this:&lt;BR /&gt;# ioscan -funC disk | grep c | grep -v Class | awk '{ print $1}'&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Tue, 07 Feb 2006 12:34:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726299#M100902</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2006-02-07T12:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726300#M100903</link>
      <description>The problem with a straighy sort is that for example t10d sorts before t2d.&lt;BR /&gt;So you need to pull apart the X, Y and Z.&lt;BR /&gt;&lt;BR /&gt;Now you can create a perl sort function that first compares X then Ys, then Zs, or you can cheat a little.&lt;BR /&gt;Create a fresh number by multiplying X by a large range (like 1000... but take your pick), then add Y and mutliply again, and finally add Z.&lt;BR /&gt;Now compare numerically. &lt;BR /&gt;Pick any number larger than the largest X and Y, but pikcing 1000 or 100 reads nicely.&lt;BR /&gt;&lt;BR /&gt;Sample script to get you going:&lt;BR /&gt;&lt;BR /&gt;------ sort_dsk.pl -----&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  if (/dsk.c(\d+)t(\d+)d(\d+)\s/) {&lt;BR /&gt;    $num = ($1*1000 +$2)*1000+$3;&lt;BR /&gt;    $dsk{$num} = $_;&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;for $key (sort {$a &amp;lt;=&amp;gt; $b} keys %dsk) {&lt;BR /&gt;   print $key, $dsk{$key};&lt;BR /&gt;   }&lt;BR /&gt;-------------&lt;BR /&gt;&lt;BR /&gt;As input example I used the data from the last reply in: &lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=718178" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=718178&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This then gives:&lt;BR /&gt;&lt;BR /&gt;$ perl sort_dsk.pl tmp.tmp&lt;BR /&gt;3000000/dev/rdsk/c3t0d0 0 0 CL1F 1:71 OPEN-3 2347 00030107 5247&lt;BR /&gt;3000001/dev/rdsk/c3t0d1 0 1 CL1F 1:72 OPEN-3 2347 00030107 5247&lt;BR /&gt;3000002/dev/rdsk/c3t0d2 0 2 CL1F 1:73 OPEN-3 2347 00030107 5247&lt;BR /&gt;&lt;BR /&gt;:&lt;BR /&gt;6004001/dev/rdsk/c6t4d1 4 1 CL1F 2:7e OPEN-9 7042 00035807 5244&lt;BR /&gt;6004002/dev/rdsk/c6t4d2 4 2 CL1F 2:7f OPEN-9 7042 00035807 5244&lt;BR /&gt;6009000/dev/rdsk/c6t9d0 9 0 CL1F 3:2c OPEN-9 0 00035807 5244&lt;BR /&gt;6010000/dev/rdsk/c6t10d0 10 0 CL1F 2:2e OPEN-9 0 00035807 5244&lt;BR /&gt;6011000/dev/rdsk/c6t11d0 11 0 CL1F 1:80 OPEN-9 0 00035807 5244&lt;BR /&gt;6012000/dev/rdsk/c6t12d0 12 0 CL1F 1:88 OPEN-9 0 00035807 5244&lt;BR /&gt;6013000/dev/rdsk/c6t13d0 13 0 CL1F 3:74 OPEN-9 0 00035807 5244&lt;BR /&gt;&lt;BR /&gt;Enjoy!&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Feb 2006 12:58:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726300#M100903</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-07T12:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726301#M100904</link>
      <description>Nelson:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'm/c(\d+)t(\d+)d(\d+)/;printf "c%02dt%02dd%02d\n",$1,$2,$3' file|sort  &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 07 Feb 2006 13:13:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726301#M100904</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-07T13:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726302#M100905</link>
      <description># perl -nle 'm/c(\d+)t(\d+)d(\d+)/;printf "c%02dt%02dd%02d\n",$1,$2,$3' list|sort&lt;BR /&gt;c01t03d00&lt;BR /&gt;c111t03d00&lt;BR /&gt;c20t03d00&lt;BR /&gt;c211t03d00&lt;BR /&gt;c21t03d00&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CLose but it adds leading zeroes...&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Feb 2006 13:30:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726302#M100905</guid>
      <dc:creator>Alzhy</dc:creator>
      <dc:date>2006-02-07T13:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726303#M100906</link>
      <description>The result I'd like from the test list should be:&lt;BR /&gt;&lt;BR /&gt;c1t3d0&lt;BR /&gt;c111t3d0&lt;BR /&gt;c20t3d00&lt;BR /&gt;c21t3d0&lt;BR /&gt;c211t3d0&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Feb 2006 13:32:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726303#M100906</guid>
      <dc:creator>Alzhy</dc:creator>
      <dc:date>2006-02-07T13:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726304#M100907</link>
      <description>Hi (again) Nelson:&lt;BR /&gt;&lt;BR /&gt;Of course:&lt;BR /&gt;&lt;BR /&gt;# cat listdevs&lt;BR /&gt;#!/usr/bin/perl &lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    m/c(\d+)t(\d+)d(\d+)/;&lt;BR /&gt;    $dev = sprintf "c%04dt%04dd%04d\n",$1,$2,$3;&lt;BR /&gt;    push @ary, $dev;&lt;BR /&gt;}&lt;BR /&gt;@sorted = sort @ary;&lt;BR /&gt;foreach (@sorted) {&lt;BR /&gt;    m/c(\d+)t(\d+)d(\d+)/;&lt;BR /&gt;    printf "c%dt%dd%d\n",$1,$2,$3;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...run as ./listdevs file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 07 Feb 2006 13:51:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726304#M100907</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-07T13:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726305#M100908</link>
      <description>&lt;BR /&gt;Didn't my example give you enough hints to get going?&lt;BR /&gt;&lt;BR /&gt;If you just want the device list then here is a minor adaption to that...&lt;BR /&gt;&lt;BR /&gt;--------------&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  if (/c(\d+)t(\d+)d(\d+)\s/) {&lt;BR /&gt;    $num = ($1*1000 +$2)*1000+$3;&lt;BR /&gt;    $dsk{$num} = "c$1t$2d$3";&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;for $key (sort {$a &amp;lt;=&amp;gt; $b} keys %dsk) {&lt;BR /&gt;   print $dsk{$key}."\n";&lt;BR /&gt;   }&lt;BR /&gt;--------------------&lt;BR /&gt;&lt;BR /&gt;fyi...  The {$a &amp;lt;=&amp;gt; $} is a localy defined sort function using a numeric compare instead of the default string compare.&lt;BR /&gt;Due to the way i contractured the artifical 'key', either should work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;------------&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  if (/c(\d+)t(\d+)d(\d+)\s/) {&lt;BR /&gt;    $num = ($1*1000 +$2)*1000+$3;&lt;BR /&gt;    $dsk{$num} = "c$1t$2d$3";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;for $key (sort keys %dsk) {&lt;BR /&gt;   print $dsk{$key}."\n";&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Feb 2006 14:02:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726305#M100908</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-07T14:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726306#M100909</link>
      <description>Here's a one-liner, but you'd have to play with the "sort" part to accomodate single &amp;amp; double-digit c#'s:&lt;BR /&gt;&lt;BR /&gt;ioscan -funC disk | grep dsk | awk -F / '{print $4}' | sort | head -1</description>
      <pubDate>Wed, 08 Feb 2006 08:28:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/best-and-fast-way-to-sort-cxtydz-values-picking-the-lowest-quot/m-p/3726306#M100909</guid>
      <dc:creator>Andy Torres</dc:creator>
      <dc:date>2006-02-08T08:28:41Z</dc:date>
    </item>
  </channel>
</rss>

