- Learning Linux Shell Scripting
- Ganesh Naik
- 81字
- 2021-06-25 22:02:50
The sort command
This command sorts the contents of a text file, line by line. The options are as follows:
- -n: Sorts as per the numeric value
- -d: Sorts as per the dictionary meaning
- -h: Compares as per the human-readable numbers (for example, 1K 2G)
- -r: Sorts in the reverse order
- -t: Option to specify a delimiter for fields
- +num: Specifies sort field numbers
- -knum: Specifies sort field numbers
- $ sort -k4 sample.txt: This will sort according to the fourth field
