Bash - uniq
uniq
writes the unique lines in the given standard input
uniq [option]… [input [output]]
- Find and then remove duplicate elements - In uniq -d is used to find duplicates and -u is used to find unique records.
uniq -d movies.csv
- Remove duplicate records - In uniq -d is used to find duplicates and -u is used to find unique records.
uniq -u movies.csv > uniq_movie.csv
- Crosscheck the new file for duplicates
uniq -d uniq_movie.csv
-c, --count - prefix lines by the number of occurrences
-d, --repeated - only print duplicate lines, one for each group
-D - print all duplicate lines
-u, --unique - only print unique lines
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.