The other day I saw a colleague of mine using sort to sort a number of lines he copied from a text file.
I've been trying to reproduce it myself and I cannot seem to find how.
The requirements are as follow:
Use sort from command line, plus whatever else you need to add to configure input
Paste the text to be sorted from the clipboard
Get the sorted result in the console
Sort a File Numerically To sort a file containing numeric data, use the -n flag with the command. By default, sort will arrange the data in ascending order. If you want to sort in descending order, reverse the arrangement using the -r option along with the -n flag in the command.
SORT command is used to sort a file, arranging the records in a particular order. By default, the sort command sorts file assuming the contents are ASCII. Using options in the sort command can also be used to sort numerically. SORT command sorts the contents of a text file, line by line.
Option -n In Unix, when you try to sort a file in a numeric way, you can use the option '-n' with the sort command. This command is used to sort the numeric contents present in the file. Be default, it sorts in ascending order.
If you type sort -
the command will accept input from stdin. Then you can just paste whatever you want into the console and type CTRL-D to sort it.
Easy, just type sort
(or sort -
) to run on stdin
, paste your lines, and hit CTRL+D for end-of-transmission to sort.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With