Sort (Unix)
Encyclopedia : S : SO : SOR : Sort (Unix)
- The correct title of this } is }}}. The initial letter is capitalized due to [Naming conventions #Lower case first lettertechnical restrictions].
Example of sort in action:
$ cat phonebookThe -n option makes the program to sort according to numerical value:Smith, Brett 555-4321 Doe, John 555-1234 Doe, Jane 555-3214 Avery, Cory 555-4321 Fogarty, Suzie 555-2314
$ cat phonebook | sort
Avery, Cory 555-4321 Doe, Jane 555-3214 Doe, John 555-1234 Fogarty, Suzie 555-2314 Smith, Brett 555-4321
$ du /bin/* | sort -nThe -n +1 option makes the program to sort according to numerical value, using the second column of data:4 /bin/domainname 4 /bin/echo 4 /bin/hostname 4 /bin/pwd ... 24 /bin/ls 30 /bin/ps 44 /bin/ed 54 /bin/rmail 80 /bin/pax 102 /bin/sh 304 /bin/csh
$ cat zipcodeThe -r option just reverses the order of the sort:Adam 12345 Bob 34567 Joe 56789 Sam 45678 Wendy 23456
$ cat zipcode | sort -n +1
Adam 12345 Wendy 23456 Bob 34567 Sam 45678 Joe 56789
$ cat zipcode | sort -nr +1Joe 56789 Sam 45678 Bob 34567 Wendy 23456 Adam 12345
See also
External links
| Unix command line programs ( ) | |||
| File and file system management: | cat | chdir/cd | chmod | chown | chgrp | cp | du | df | fdupes | file | fsck | ln | ls | lsof | mkdir | more | mount | mv | pwd | rcp | rm | rmdir | split | touch | tree | ||
| Process management: | anacron | at | chroot | cron/crontab | kill | nice | ps | sleep | time | timex | top | renice | wait | ||
| User Management/Environment: | env | finger | id | locale | mesg | passwd | su | sudo | uname | uptime | w | who | write | ||
| Text processing: | awk | cut | diff | ex | head | iconv | join | less | more | nkf | paste | sed | sort | tail | tr | uniq | wc | xargs | ||
| Shell programming: | echo | expr | unset | Printing: | lp |
| Communications: inetd | netstat | ping | rlogin | traceroute | Searching: egrep | fgrep | find | grep | strings | Miscellaneous: banner | bc | cal | man | uname | wall | yes | |
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
