For example, the following command: sort -r data.txt You can perform a reverse-order sort using the -r flag. Using the -o option is functionally the same as redirecting the output to a file neither one has an advantage over the other. You can also use the built-in sort option -o, which allows you to specify an output file: sort -o output.txt data.txt To check the output, use the cat command: cat output.txt which will not display any output, but will create the file output.txt with the same sorted data from the previous command. files0-from= F Options -b,Ĭonsider only blanks and alphanumeric characters.įold lower case to upper case characters.Ĭompare according to general numerical value. The rules for sorting can be changed according to the options you provide to the sort command these are listed below. Lines starting with a lowercase letter will appear before lines starting with the same letter in uppercase.Lines starting with a letter that appears earlier in the alphabet will appear before lines starting with a letter that appears later in the alphabet.Lines starting with a number will appear before lines starting with a letter.Sort is a simple and very useful command which will rearrange the lines in a text file so that they are sorted, numerically and alphabetically.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |