KandZ – Tuts

We like to help…!

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!

Leave a Reply