uniq command
The uniq command is used for filtering out the unique characters from a file containing duplicate input data.
Syntax of uniq command:
uniq [OPTION] [INPUT[OUTPUT]]
Sample code:
Let us try creating a text file names.txt that contains several duplicate names of input data.
cat > names.txt
Now, let’s see the functionality of uniq command in filtering the above duplicate data :
uniq -c names.txt
Output:
Explanation:
We have only displayed the unique data or contents from the names.txt file by using uniq command.
Useful Commands For Filtering Text for Effective File Operations in Linux
In this article, let us learn about different commands used in Linux for filtering text to implement effective file operations on Linux Machines.