Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a keyboard shortcut in Atom for removing duplicates in a text file?

I have a list of values like so:
CAT
Dog
cat
Cow
dOg

I want it to have unique entries in quotes like this:
'CAT'
'Dog'
'Cow'

Is there a shortcut in Atom for this?

like image 254
AJES123 Avatar asked Nov 06 '15 18:11

AJES123


People also ask

How do I remove duplicates in a text file?

The uniq command is used to remove duplicate lines from a text file in Linux. By default, this command discards all but the first of adjacent repeated lines, so that no output lines are repeated. Optionally, it can instead only print duplicate lines. For uniq to work, you must first sort the output.

Which keyboard is used to remove duplicates?

Answer : DISTINCT. The SQL DISTINCT keyword is used after the SELECT statement and is used to eliminate all the duplicate records and fetch the unique records.


2 Answers

Not at the moment. But if you are on a POSIX like system (Linux and MacOS by default, Windows with some help), you can make use of the atom package 'pipe'

Just mark your text and pipe it through this command:

sort -f | uniq -i

or with the long options (yes, sort has -f and uniq -i):

sort --ignore-case | uniq --ignore-case

On my system that results in:

cat
Cow
dOg

Please note that uniq want's its input sorted and similar entries following each other. Thats why your need to sort them first

like image 170
M-x Avatar answered Oct 23 '22 20:10

M-x


atom now has a plugin called duplicate-removal which will remove duplicate lines automatically

https://atom.io/packages/duplicate-removal

like image 43
mihai Avatar answered Oct 23 '22 19:10

mihai