Linux CLI 42 ๐ง sort and uniq commands
a - sort command
sort command is used to sort text files
syntax โ sort [options] [file...]
common options: -n โ sorts numerically -o โ specifies an output file
-f โ case insensitive sorting -u โ sorts and removes duplicate lines
-c โ checks if file is already sorted -r โ sorts in reverse order
sort -r fruit.txt โ sorts text file in reverse order
sort fruit.txt โ sorts text file
sort -o sorted.txt fruit.txt โ sorts text file and save it to sorted.txt
ls | sort -r โ using pipes, sorting the directory contents
b - uniq command
uniq command is used to report repeated lines in a sorted file
It is also used to filter out repeated lines
syntax โ uniq [options] [inputfile]
common options: -c โ shows number of occurrences of each line. -d โ shows only repeated lines
-u โ only print unique lines -s # โ skip first # characters in lines
uniq fruit.txt โ removing consecutive duplicates
uniq -c fruit.txt โ counts occurences of lines
uniq -d fruit.txt โ shows only duplicate lines
uniq -u fruit.txt โ shows only unique lines
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!