- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sort command question
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
тАО08-18-2004 08:18 PM
тАО08-18-2004 08:18 PM
I used the following command
sort -t, -k 3,2 data.csv
but it ends up sorting by column 2 then by column 3 only
how should I sort by column 3 then column 2??
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2004 08:36 PM
тАО08-18-2004 08:36 PM
Re: sort command question
Try
sort -t, -k 3,3 -k 2,2 data.csv
steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2004 08:44 PM
тАО08-18-2004 08:44 PM
Re: sort command question
cat
should do the trick
Regards
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2004 08:50 PM
тАО08-18-2004 08:50 PM
Solution-k 3,2
start point of key = 3
end point ok key = 2
Man page -->
The characters at positions
field_start and field_end are included in the key
field, providing that field_end does not precede
field_start.
IF you want to sort based on column 3 first then column 2 next then,
use two keys as,
-k 3 -k 2 ( -k 3,3 -k 2,2 )
it will process sorting with 3rd field then 2nd field.
Examples:
Master1 # cat /tmp/for.log
hai,23,4
bye,56,1
you,67,2
me,34,6
Master1 # sort -t , -k 3 -k 2 /tmp/for.log
bye,56,1
you,67,2
hai,23,4
me,34,6
Master1 # sort -t , -k 3,2 /tmp/for.log
bye,56,1
hai,23,4
me,34,6
you,67,2
Regards
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2004 09:09 PM
тАО08-18-2004 09:09 PM
Re: sort command question
sort -t, -k 3,3 -k 2,2
works