Skip to content

Instantly share code, notes, and snippets.

@ejoubaud
Created May 8, 2013 05:19
Show Gist options
  • Save ejoubaud/5538381 to your computer and use it in GitHub Desktop.
Save ejoubaud/5538381 to your computer and use it in GitHub Desktop.
Awk for Turtlestein: Find duplicates elements in a list
# Find duplicates in a textual list
#
# Just:
# * paste the list into Sublime
# * paste this line in Shell Turtlestein (plugin) invite
# * replace $1 by $<element_column_index> if there are more than 1 column
# * add flag -F if columns separator is not default (spaces and tabs)
#
# Can be easily adapted for VIM, it's just awk
| awk '{ items[$1] = items[$1] + 1 } END { for (item in items) { if (items[item] > 1) { print item ": " items[item] } } }' >
<<COMMENT
2001
102
12
2001
100
becomes
2001: 2
COMMENT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment