Intermediate
Linux & Shell Scripting
Q62 / 100
What does the "uniq" command do, and what is a common gotcha when using it?
Correct! Well done.
Incorrect.
The correct answer is A) "uniq" filters out adjacent duplicate lines from sorted input; a common gotcha is that it only removes consecutive duplicates, so input often needs to be sorted first (e.g. "sort file | uniq") to remove all duplicates regardless of order
A
Correct Answer
"uniq" filters out adjacent duplicate lines from sorted input; a common gotcha is that it only removes consecutive duplicates, so input often needs to be sorted first (e.g. "sort file | uniq") to remove all duplicates regardless of order
Explanation
Because "uniq" only compares adjacent lines, non-adjacent duplicates won't be removed unless the input is sorted first, making "sort | uniq" a common idiom for true deduplication.
Progress
62/100