Skip to content

Instantly share code, notes, and snippets.

@felixrabe
Created June 3, 2013 10:01
Show Gist options
  • Save felixrabe/5697235 to your computer and use it in GitHub Desktop.
Save felixrabe/5697235 to your computer and use it in GitHub Desktop.
occur
#!/usr/bin/env coffee
readline = require 'readline'
occ = Object.create null
# http://stackoverflow.com/a/15554600
rd = readline.createInterface
input: process.stdin
output: process.stdout
terminal: false
rd.on 'line', (line) ->
occ[line] ?= 0
occ[line] += 1
rd.on 'close', ->
console.log occ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment