Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool that will remove duplicate lines from a file? [closed]

Is there a mac file comparison tool that can detect duplicates within a file? This is very close to what I'm looking for except it is for Windows: http://www.rlvision.com/dupli/about.asp. Also, I need to compare duplicate content across two files. If nothing else, I can just append file2 content to the bottom of file1.

like image 740
4thSpace Avatar asked Sep 29 '11 04:09

4thSpace


People also ask

How do I remove duplicate lines in files?

Remove duplicate lines with uniq If you don't need to preserve the order of the lines in the file, using the sort and uniq commands will do what you need in a very straightforward way. The sort command sorts the lines in alphanumeric order. The uniq command ensures that sequential identical lines are reduced to one.

Which command is used to remove the duplicate records in file?

Uniq command is helpful to remove or detect duplicate entries in a file.

Which of the following filter is used to remove duplicate lines?

Explanation: uniq : Removes duplicate lines.


1 Answers

I don't know of a GUI app to do it, but it's fairly easy at the terminal:

cat file1.txt file2.txt | sort | uniq -d

The -d will make it show only duplicate lines. If you just want the output without duplicates, just leave off the -d.

like image 83
BJ Homer Avatar answered Nov 15 '22 20:11

BJ Homer