- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- What can this sort command do?
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
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
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
тАО05-28-2001 11:22 PM
тАО05-28-2001 11:22 PM
#sort -t: +2n -3 /etc/passwd
Can someone tell me how to interpret this?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2001 11:45 PM
тАО05-28-2001 11:45 PM
Re: What can this sort command do?
This sort command basically displays the passwd file sorted by UID (the 3rd field).
The -t: command means use the colan as a field separator (instead of a space or tab), then the normal sort notation of +X -Y means to sort by fields X to Y, in this case 2 to 3 (the UID is the 3rd field in the passwd file after userid and password), so sort after 2 and until the 3rd field. The n on +2n means sort numerically (as opposed to alphabetically) as the UID field are numbers.
See man on sort for more detailed info.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2001 12:14 AM
тАО05-29-2001 12:14 AM
Solutionfederico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2001 12:22 AM
тАО05-29-2001 12:22 AM
Re: What can this sort command do?
I did a test and it seems getting the same result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2001 12:59 AM
тАО05-29-2001 12:59 AM
Re: What can this sort command do?
there is no difference between +2n -3 or just using +2n. Just using +2n means do the sort calculation until the next field separator, which in this case is a colan so the result is the same. However, good practice is to use the full sort command format, field +X to -Y, if you use the sort command to sort other files you may need the -Y so good practicse is to use it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2001 05:25 PM
тАО05-29-2001 05:25 PM
Re: What can this sort command do?
sort -t: -k 4n,4 -k 3n,3 /etc/passwd ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2001 10:10 PM
тАО05-29-2001 10:10 PM
Re: What can this sort command do?
federico