<?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: disk sorting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768228#M942507</link>
    <description>&lt;BR /&gt;I used this posix script recently.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;ls -1 /dev/dsk | while IFS="ctd${IFS}" read ignore1 c t d ignore2&lt;BR /&gt;do&lt;BR /&gt;        print $c $t $d&lt;BR /&gt;done | sort -n -k1n -k2n -k3n | while read c t d ignore&lt;BR /&gt;do&lt;BR /&gt;        print c${c}t${t}d${d}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;As you can see, I thorougly enjoy using the 'while read' method where possible.&lt;BR /&gt;</description>
    <pubDate>Fri, 19 Jul 2002 17:21:39 GMT</pubDate>
    <dc:creator>Jordan Bean</dc:creator>
    <dc:date>2002-07-19T17:21:39Z</dc:date>
    <item>
      <title>disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768224#M942503</link>
      <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;Suppose, I have the following disks:&lt;BR /&gt;c1t0d0&lt;BR /&gt;c2t0d0&lt;BR /&gt;c3t1d0&lt;BR /&gt;c4t0d0&lt;BR /&gt;c3t0d0&lt;BR /&gt;c1t0d2&lt;BR /&gt;c1t2d0&lt;BR /&gt;&lt;BR /&gt;basic format is : cXtYdZ&lt;BR /&gt;and I want to sort using first X, then Y and then Z.&lt;BR /&gt;The following sort does a good job:&lt;BR /&gt;sort -t 'd' -k 1,2n -k1.1b,1.2b diskCollection&lt;BR /&gt;&lt;BR /&gt;until, I have X as a double digit, e.g.&lt;BR /&gt;c11t6d0...&lt;BR /&gt;&lt;BR /&gt;it puts c11t6d0 in front for reason.&lt;BR /&gt;&lt;BR /&gt;Does anyone know how to force it for sort in a correct way?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 16:42:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768224#M942503</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-07-19T16:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768225#M942504</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;cat diskCollection | sed "s/^c\(.*\)t\(.*\)d\(.*\)/\1 \2 \3/" | sort -t" " -k1n -k2n -k3n|sed -e "s/^/c/" -e "s/ /t/" -e "s/ /d/"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 19 Jul 2002 16:55:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768225#M942504</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-07-19T16:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768226#M942505</link>
      <description>yowser!&lt;BR /&gt;&lt;BR /&gt;You could try to create the list with ll /dev/dsk/ sorted.&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 17:07:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768226#M942505</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-07-19T17:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768227#M942506</link>
      <description>oops, that what that was!&lt;BR /&gt;&lt;BR /&gt;aahh, &lt;BR /&gt;Perhaps, ioscan could do it:&lt;BR /&gt;&lt;BR /&gt;for i in $(ioscan -fnkC ext_bus | grep ext_bus | cut -d" " -f4)&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; ls /dev/dsk/c${i}t* | grep -v not&lt;BR /&gt;&amp;gt; done&lt;BR /&gt;&lt;BR /&gt;on second thoughts, then there's the target to add in there in a second loop, it's easier to stick with Harry solution afterall!&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 17:17:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768227#M942506</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-07-19T17:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768228#M942507</link>
      <description>&lt;BR /&gt;I used this posix script recently.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;ls -1 /dev/dsk | while IFS="ctd${IFS}" read ignore1 c t d ignore2&lt;BR /&gt;do&lt;BR /&gt;        print $c $t $d&lt;BR /&gt;done | sort -n -k1n -k2n -k3n | while read c t d ignore&lt;BR /&gt;do&lt;BR /&gt;        print c${c}t${t}d${d}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;As you can see, I thorougly enjoy using the 'while read' method where possible.&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 17:21:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768228#M942507</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2002-07-19T17:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768229#M942508</link>
      <description>Hi Harry,&lt;BR /&gt;&lt;BR /&gt;Your solution worked perfectly.&lt;BR /&gt;&lt;BR /&gt;Unfortunately, I will have disk in the file in this kind of format, and the code you showed didn't actually work for this format.&lt;BR /&gt;&lt;BR /&gt;c1t8d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c0t9d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 1&lt;BR /&gt;c0t11d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 2&lt;BR /&gt;&lt;BR /&gt;do you know what is needed to be changed in your code?&lt;BR /&gt;&lt;BR /&gt;Thank you very much!</description>
      <pubDate>Fri, 19 Jul 2002 18:26:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768229#M942508</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-07-19T18:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768230#M942509</link>
      <description>You can change Harry's script to-&lt;BR /&gt;&lt;BR /&gt;cat diskCollection | sed "s/^c\(.*\)t\(.*\)d\(\[0-9\]*\)/\1 \2 \3/" | sort -t" " -k1n -k2n -k3n|sed -e "s/^/c/" -e "s/ /t/" -e "s/ /d/" &lt;BR /&gt;&lt;BR /&gt;This is by changes (.*) to ([0-9]*) means to scan only for numerics following the "d".&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 18:38:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768230#M942509</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-19T18:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768231#M942510</link>
      <description>Unfortunately, it doesn't seem to work.&lt;BR /&gt;&lt;BR /&gt;cc0t11d0tNONEd4095 JBOD/Other SEAGATE ST34573WC 2&lt;BR /&gt;cc0t9d0tNONEd4095 JBOD/Other SEAGATE ST34573WC 1&lt;BR /&gt;cc1t8d0tNONEd4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 18:46:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768231#M942510</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-07-19T18:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768232#M942511</link>
      <description>Andi,&lt;BR /&gt;&lt;BR /&gt;I tried your extended example and it still worked. Can you post what you used?&lt;BR /&gt;&lt;BR /&gt;Also, using Rodney's modified because his drops the text, unless that's what you want, anyways here:&lt;BR /&gt;&lt;BR /&gt;Oh wait, you do want to drop the text, correct? If so, use Rodney's. - I'm babnling, I think I need a drink SOON.&lt;BR /&gt;&lt;BR /&gt;this keeps the text:&lt;BR /&gt;&lt;BR /&gt;cat yank | sed "s/^c\(.*\)t\(.*\)d\([0-9]*\)\(.*\)/\1 \2 \3\4/" | sort -t" " -k1&lt;BR /&gt;n -k2n -k3n|sed -e "s/^/c/" -e "s/ /t/" -e "s/ /d/"&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 18:48:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768232#M942511</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-07-19T18:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768233#M942512</link>
      <description>andi,&lt;BR /&gt;&lt;BR /&gt;If you want to "drop" the text use this:&lt;BR /&gt;&lt;BR /&gt;cat yank | sed "s/^c\(.*\)t\(.*\)d\([0-9]*\)\(.*\)/\1 \2 \3/" | sort -t" " -k1n&lt;BR /&gt;-k2n -k3n|sed -e "s/^/c/" -e "s/ /t/" -e "s/ /d/"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 19 Jul 2002 18:51:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768233#M942512</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-07-19T18:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768234#M942513</link>
      <description>andi,&lt;BR /&gt;&lt;BR /&gt;this is the file I used:&lt;BR /&gt;&lt;BR /&gt;# cat yank                                                                    &lt;BR /&gt;c1t8d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0 &lt;BR /&gt;c0t9d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 1 &lt;BR /&gt;c0t11d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 2 &lt;BR /&gt;c1t0d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c1t10d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c1t10d1 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c1t10d5 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c11t6d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c1t10d30 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c2t0d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c3t1d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c4t0d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c3t0d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c1t0d2 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;c1t2d0 NONE 4095 JBOD/Other SEAGATE ST34573WC 0&lt;BR /&gt;# &lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 19 Jul 2002 18:54:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768234#M942513</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-07-19T18:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768235#M942514</link>
      <description>If you want to incorporate perl here, try this&lt;BR /&gt;&lt;BR /&gt;cat input | perl -p -e '/^c(\d+)t(\d+)d(\d+)/;$a=100+$1;$b=100+$2;$c=100+$3;s/^/$a$b$c\t/;' | sort -n | cut -f 2-&lt;BR /&gt;&lt;BR /&gt;This will extract the 3 numerics, put them into a fixed format. The output will then be piped to sort and finally to cut to remove the sort key.&lt;BR /&gt;&lt;BR /&gt;hope this helps...&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 19 Jul 2002 18:54:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768235#M942514</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-07-19T18:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768236#M942515</link>
      <description>Changing Jordan's script just a little, this should work (and lines up the data nicely):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -L9 DISK&lt;BR /&gt;while IFS="ctd${IFS}" read C T D RESTOFLINE&lt;BR /&gt;do&lt;BR /&gt;print $C $T $D "$RESTOFLINE"&lt;BR /&gt;done | sort -n -k1n -k2n -k3n | while read C T D REPLY&lt;BR /&gt;do&lt;BR /&gt;DISK="c${C}t${T}d${D}"&lt;BR /&gt;print "$DISK $REPLY"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Usage: cat YourFile | ./thisScript&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Jul 2002 18:54:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768236#M942515</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2002-07-19T18:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768237#M942516</link>
      <description>Hi Harry,&lt;BR /&gt;&lt;BR /&gt;Your script works perfectly.&lt;BR /&gt;&lt;BR /&gt;Unfortunately, if I have alternate path disk instead of NONE, I get some screwed values:&lt;BR /&gt;e.g.&lt;BR /&gt;c1t8d0 c1t0d1 4095 JBOD/Other               &lt;BR /&gt;c0t9d0 NONE 4095 JBOD/Other    &lt;BR /&gt;&lt;BR /&gt;Do you know how I can ignore the 2nd disk, and make it behave as was NONE?&lt;BR /&gt;&lt;BR /&gt;Here is the script I used:&lt;BR /&gt;cat $TMPDIR/DiskSelection.$$ | sed "s/^c\(.*\)t\(.*\)d\(.*\)/\1 \2 \3/" | sort -t" " -k1n -k2n -k3n|sed -e "s/^/c/" -e "s/ /t/" -e "s/ /d/" &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!</description>
      <pubDate>Mon, 22 Jul 2002 16:55:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768237#M942516</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-07-22T16:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: disk sorting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768238#M942517</link>
      <description>Andi,&lt;BR /&gt;&lt;BR /&gt;change the "sed" to look for an "N" or a "c" in the second column:&lt;BR /&gt;&lt;BR /&gt;sed "s/^c\(.*\)t\(.*\)d\(.*\) \([Nc].*\)/\1 \2 \3 \4/"&lt;BR /&gt;&lt;BR /&gt;If you want to "drop" the text just omit the " \4"&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 29 Jul 2002 14:14:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-sorting/m-p/2768238#M942517</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-07-29T14:14:47Z</dc:date>
    </item>
  </channel>
</rss>

