The uniq command on Linux removes duplicate lines from an ordered file. That’s why it’s often used in conjunction with the sort command.
The most common options are:
Without sorting, uniq is unable to eliminate duplicates. See the example below:
$ uniq supermarket rice beans meat potato lettuce tomato rice meat
$ sort supermarket | Uniq lettuce rice potato meat beans tomato
The uniq command is very useful for removing duplicates from files with a data source, especially text files, CSV files, etc.
The “-i” option causes uniq to ignore whether items are capitalized or lowercase.
The “-D” option shows only duplicate lines:
$ sort supermarket | Uniq -D rice rice meat meat
The sudo command on Linux executes a given command as if it were another user.…
The ss command on Linux is extremely useful for investigating sockets, providing various information about…
Free Linux command shows the amount of total memory in use and available, as well…
The shell has structures for testing conditions and executing certain program sequences several times (loop),…
The /etc/fstab file stores the configuration of which devices should be mounted and what is…
The Netcat Command in Linux or nc is a utility used to do “almost anything”…
This website uses cookies.