How To Use The Sort Command In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. To sort a file alphabetically, use the following command:
sort <filename>
2. To sort a file numerically, use the following command:
sort -n <filename>
3. To sort a file in reverse (descending) order, use the following command:
sort -r <filename>
4. To sort a file ignoring case, use the following command:
sort -f <filename>
5. To sort a file based on the fourth field, use the following command:
sort -k 4 <filename>
6. To specify a delimiter for fields, use the following command:
sort -t <delimiter> <filename>
7. To sort a file based on the second field, ignoring case, use the following command:
sort -k 2 -f <filename>