- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Best and fast way to sort cXtYdZ values picking th...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 04:18 AM
тАО02-07-2006 04:18 AM
Best and fast way to sort cXtYdZ values picking the lowest "c" value?
Suggestions? More points to Perl constructs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 04:21 AM
тАО02-07-2006 04:21 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
Perl from someone else
ls | /dev/dsk/c* | sort -rn
take out the r if it comes out backwards.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Tags:
- Sort
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 04:30 AM
тАО02-07-2006 04:30 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
In perl, make a call to a system command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 04:32 AM
тАО02-07-2006 04:32 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
Does this output not sorted.
If i understood the question the output of the command above is what you are expecting.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 04:34 AM
тАО02-07-2006 04:34 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
# ioscan -funC disk | grep c | grep -v Class | awk '{ print $1}'
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 04:58 AM
тАО02-07-2006 04:58 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
So you need to pull apart the X, Y and Z.
Now you can create a perl sort function that first compares X then Ys, then Zs, or you can cheat a little.
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.
Now compare numerically.
Pick any number larger than the largest X and Y, but pikcing 1000 or 100 reads nicely.
Sample script to get you going:
------ sort_dsk.pl -----
while (<>) {
if (/dsk.c(\d+)t(\d+)d(\d+)\s/) {
$num = ($1*1000 +$2)*1000+$3;
$dsk{$num} = $_;
}
}
for $key (sort {$a <=> $b} keys %dsk) {
print $key, $dsk{$key};
}
-------------
As input example I used the data from the last reply in: http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=718178
This then gives:
$ perl sort_dsk.pl tmp.tmp
3000000/dev/rdsk/c3t0d0 0 0 CL1F 1:71 OPEN-3 2347 00030107 5247
3000001/dev/rdsk/c3t0d1 0 1 CL1F 1:72 OPEN-3 2347 00030107 5247
3000002/dev/rdsk/c3t0d2 0 2 CL1F 1:73 OPEN-3 2347 00030107 5247
:
6004001/dev/rdsk/c6t4d1 4 1 CL1F 2:7e OPEN-9 7042 00035807 5244
6004002/dev/rdsk/c6t4d2 4 2 CL1F 2:7f OPEN-9 7042 00035807 5244
6009000/dev/rdsk/c6t9d0 9 0 CL1F 3:2c OPEN-9 0 00035807 5244
6010000/dev/rdsk/c6t10d0 10 0 CL1F 2:2e OPEN-9 0 00035807 5244
6011000/dev/rdsk/c6t11d0 11 0 CL1F 1:80 OPEN-9 0 00035807 5244
6012000/dev/rdsk/c6t12d0 12 0 CL1F 1:88 OPEN-9 0 00035807 5244
6013000/dev/rdsk/c6t13d0 13 0 CL1F 3:74 OPEN-9 0 00035807 5244
Enjoy!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 05:13 AM
тАО02-07-2006 05:13 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
# perl -nle 'm/c(\d+)t(\d+)d(\d+)/;printf "c%02dt%02dd%02d\n",$1,$2,$3' file|sort
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 05:30 AM
тАО02-07-2006 05:30 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
c01t03d00
c111t03d00
c20t03d00
c211t03d00
c21t03d00
CLose but it adds leading zeroes...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 05:32 AM
тАО02-07-2006 05:32 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
c1t3d0
c111t3d0
c20t3d00
c21t3d0
c211t3d0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2006 05:51 AM
тАО02-07-2006 05:51 AM
Re: Best and fast way to sort cXtYdZ values picking the lowest "c" value?
Of course:
# cat listdevs
#!/usr/bin/perl
while (<>) {
m/c(\d+)t(\d+)d(\d+)/;
$dev = sprintf "c%04dt%04dd%04d\n",$1,$2,$3;
push @ary, $dev;
}
@sorted = sort @ary;
foreach (@sorted) {
m/c(\d+)t(\d+)d(\d+)/;
printf "c%dt%dd%d\n",$1,$2,$3;
}
...run as ./listdevs file
Regards!
...JRF...