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
Forums
Discussions
Discussions
Discussions
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
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
04-11-2002 10:27 AM
04-11-2002 10:27 AM
For example, I have the following file:
/dev/vg00,/dev/vg00/lvol1,0,25,0,0,0,22,2,100
/dev/vg00,/dev/vg00/lvol2,0,256,0,,0,0,2,1024
/dev/vg00,/dev/vg00/lvol3,0,38,0,0,1,1,2,152
/dev/vg00,/dev/vg00/lvol4,0,25,0,0,0,0,0,100
I'd like to sort the above lines by # of stripes. It is field #8. (where you see 22)
What is the best way to sort the above file, so I have no striped lvol (0) first followed by stripped ones?>
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 10:32 AM
04-11-2002 10:32 AM
Re: sorting
sort -t, -k8
You can reverse the order with -r. -k is the field number (-k2 sorts by lvol)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 10:34 AM
04-11-2002 10:34 AM
Re: sorting
sort -t , -k 8 [filename]
HTH
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 10:39 AM
04-11-2002 10:39 AM
Re: sorting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 12:07 PM
04-11-2002 12:07 PM
Re: sorting
Here is my original file:
1 2 /dev/vg00 /dev/vg00/lvol2 0 256 0 0 0 1 2 1024
1 09 /dev/vgsys /dev/vgsys/lvm 0 125 0 25 0 0 0 1000
1 10 /dev/vgsys /dev/vgsys/lvk 0 125 0 0 0 0 0 1000
1 11 /dev/vgsys /dev/vgsys/lvp 0 125 0 4 0 0 0 1000
1 12 /dev/vgsys /dev/vgsys/lvs 0 125 0 0 0 0 0 1000
1 13 /dev/vgsys /dev/vgsys/lvu 0 50 0 4 0 0 0 400
# sort -t, -r k 8 tmp > tmpSorted
Here is sorted output:
1 13 /dev/vgsys /dev/vgsys/lvu 0 50 0 4 0 0 0 400
1 12 /dev/vgsys /dev/vgsys/lvs 0 125 0 0 0 0 0 1000
1 11 /dev/vgsys /dev/vgsys/lvp 0 125 0 4 0 0 0 1000
1 10 /dev/vgsys /dev/vgsys/lvk 0 125 0 0 0 0 0 1000
1 09 /dev/vgsys /dev/vgsys/lvm 0 125 0 25 0 0 0 1000
1 02 /dev/vg00 /dev/vg00/lvol2 0 256 0 0 0 1 2 1024
Doesn't seem to sort?
Any ideas why?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 12:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 12:14 PM
04-11-2002 12:14 PM
Re: sorting
Your representation of the data originally showed the field delimiter being a comma (',') and hence the '-t,' option was specified to 'sort'. Therefore, if you input is comma delimited, use '-t,' but if it is space delimited as you show, drop the '-t,' option from the sort specification.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 12:19 PM
04-11-2002 12:19 PM
Re: sorting
As Clay suggested, the -t is used to specify the 'character' in the input file.
If you don't have the ',' in the file, then use:
# sort -r -k3 file_name
If you don't use -t it will assume the 'character' as blank.
HTH,
Shiju
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2002 12:23 PM
04-11-2002 12:23 PM
Re: sorting
# sort -r -k8 tmp > tmpsorted
HTH,
Shiju