sort and remove duplicate lines
Sort lines, keep each once, count how often each appears.
text
steps
-
sort file.txtsort the lines
-
sort -u file.txtsort them and keep each once
-
sort file.txt | uniq -c | sort -rnhow often each line appears, most first
-
awk '!seen[$0]++' file.txtkeep each once, in their order
-
sort -t, -k3 -n data.csvsort a CSV by its third column, as numbers
-
sort -h sizes.txtsort sizes like 2K, 1M, 3G
notes
- uniq only removes repeats next to each other: sort first.
commands used
sortuniqawk
Each has a page in lore: lore sort opens it.
add up numbers in a file
Sum a column of numbers, from a file or a command's output.
compare two folders
Find which files differ between two folders, or are only in one of them.
count lines of code
How many lines of code a project has, in total and by language.
count lines, words and files
Count the lines of a file or of a command's output, the words, and the files in a folder.