Skip to content

Instantly share code, notes, and snippets.

@javascriptlove
Created September 19, 2018 13:36
Show Gist options
  • Save javascriptlove/2c3bde6e185fc22661f65b48a67103b2 to your computer and use it in GitHub Desktop.
Save javascriptlove/2c3bde6e185fc22661f65b48a67103b2 to your computer and use it in GitHub Desktop.
Remove duplicate lines from file
const fs = require('fs');
const lines = fs.readFileSync('source.txt', { encoding: 'utf8' });
const unique_lines = [...new Set(lines.split("\n"))];
fs.writeFileSync('output.txt', unique_lines.join(","));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment