Last active
April 26, 2024 07:59
-
-
Save ad1992/802ce394b636a8b48077e776b6b7f339 to your computer and use it in GitHub Desktop.
Find duplicates in a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const filePath = process.argv[2]; | |
if (!filePath) { | |
console.error("Please provide a file path"); | |
process.exit(1); | |
} | |
const data = fs.readFileSync(filePath, "utf8"); | |
const data_array = data.trim().split("\n"); | |
const duplicates = data_array.filter((item, index, self) => { | |
return self.indexOf(item) !== index; | |
}); | |
console.log(duplicates); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment