I am writing a script to manipulate a text file.
First thing I want to do is check if duplicate entries exist and if so, ask the user whether we wants to keep or remove them.
I know how to display duplicate lines if they exist, but what I want to learn is just to get a yes/no answer to the question "Do duplicates exist?"
It seems uniq
will return 0
either if duplicates were found or not as long as the command completed without issues.
What is that command that I can put in an if
-statement just to tell me if duplicate lines exist?
My file is very simple, it is just values in single column.
HighlightRepeats
method in stackoverflow.com/questions/1268032. I often use it to filter duplicate files/folders, then apply shell commands on the filtered file. – Reside