5 examples for sort

11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  # Sort a file alphabetically:
sort filename
 
# Sort your command history alphabetically, skipping the command number:
history | sort -k 2
# Lines look like this:
#     23 anothercommand
#     22 somecommand
#     24 stillanothercommand
 
# Sort files by number of matches in grep results:
grep -c searchterm * | sort -t: -n -k 2
# Lines look like this:
#     filename:2
#     anotherfile:3
 
# Sort files by human readable size in a directory:
du -h --max-depth=1 | sort -h
# Lines look like this:
#     4.0K    ./SomeDirectory
#     12K     ./AnotherDirectory
#     2.4M    ./SomeFile
#     1.5G    ./LargeFile
1
1
2
  # Sort the contents of all .csv files in a directory
sort /path/to/directory/*.csv
1
1
2
  # duplicate lines line count statistics
sort filename | uniq -cd |sort -nr
0
1
2
3
  # Sort in parallel, specifying the number of concurrent operations.
sort --parallel=<num_ops>
        </num_ops>
-1
1
2
3
  # Ordenas la lista de caracteres donde
# t: Limitador -k Numero del campo -r ordenacion inversa
sort -t: -n -k3 -r password.txt