-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathsort
More file actions
23 lines (16 loc) · 754 Bytes
/
sort
File metadata and controls
23 lines (16 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Show the sorted version of file
sort test.txt
# Show the sorted version of file in the reverse order
sort -r test.txt
# Show the sorted version of file according to 2nd column (n is used if column contains numerical values)
sort -nk2 test.txt
# Show the sorted version of file according to 3rd column (no numerical value in column 3)
sort -k3 test.txt
# Use sort command with a pipeline (without any file)
ls -lah | sort -nk2
# Sort the lines and remove duplicates (again this is just showing, not changing any content)
sort -u test.txt
# Sort the contents of 2 files and concetenate the output
sort file1.txt file2.txt
# Sort the contents of 2 files and concetenate the output, then remove the duplicates
sort -u file1.txt file2.txt