Linux CLI 42 🐧 sort and uniq commands

Published: 08 February 2025
on channel: TutsKGR OS
7
0

Thanks for watching.
Any thoughts? Write a comment.
If you liked the video, Like and Subscribe.
It helps to create more videos!

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

#linux #shell #cli #konsole #ubuntu #fedora #opensuse


On this page of the site you can watch the video online Linux CLI 42 🐧 sort and uniq commands with a duration of hours minute second in good quality, which was uploaded by the user TutsKGR OS 08 February 2025, share the link with friends and acquaintances, this video has already been watched 7 times on youtube and it was liked by 0 viewers. Enjoy your viewing!