How to sort data in a file in Linux.
Most times we have some of these old files that we need to sort. Usually these files are made without technology in mind. Now we have technology to help us have well organised data.
Here we are going to do some simple sorting using the Linux OS. So we start with a pretty scattered list of names and we will sort the names in alphabetical order.
Here we use the sort command to arrange the names in the file alphabetically.
In the above example the file still maintains its scattered form, it only displays its data in alphabetical order.
Most times, we would want a modified file that we will want to use at a later date.
Here, we can transfer the changes to another file using the –o option followed by the name of the file we want to transfer the changes to.
In this case we are having a scattered list of numbers, using the sort command with the –n option on the file name helps to arrange the numbers in ascending order.
Here we have a list of months that are scattered. Using the sort command with the –M option on the file name, we can arrange all of the months accordingly.
Hope this was a helpful tutorial.