The sort command in Linux sorts the lines of a file. Once ordered, a file can be processed by other commands, such as removing duplicate occurrences with the uniq command.
Your options are:
As an example, let’s sort an email archive:
$ sort emails alessandra@empresa.com
arthur@empresa.com
carla@empresa.com
demetrios@empresa.com
flavia@empresa.com
paulo@empresa.com
root@empresa.com
uira@empresa.com
Care must be taken when ordering numbers. See the example of the unordered file below:
$ cat numbers 330 40 4 3 31 19 1
When using sort without any parameters, it sorts first using the first byte, then the second:
$ sort numbers 1 19 3 31 330 4 40
To sort using numbers as characters, you can use the -n option, or the -h option to sort in human format:
$ sort -n numbers 1 3 4 19 31 40 330
The sudo command on Linux executes a given command as if it were another user.…
The ss command on Linux is extremely useful for investigating sockets, providing various information about…
Free Linux command shows the amount of total memory in use and available, as well…
The shell has structures for testing conditions and executing certain program sequences several times (loop),…
The /etc/fstab file stores the configuration of which devices should be mounted and what is…
The Netcat Command in Linux or nc is a utility used to do “almost anything”…
This website uses cookies.