Skip to content

Instantly share code, notes, and snippets.

@jehiah
Created May 9, 2018 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jehiah/8e0ea5c9012ff1d4aff287579050a77b to your computer and use it in GitHub Desktop.
Save jehiah/8e0ea5c9012ff1d4aff287579050a77b to your computer and use it in GitHub Desktop.
Script to filter output from `uniq -c` to only items that appear more than `--frequency=n` times.
#!/bitly/local/bin/python
import tornado.options
import logging
import sys
if __name__ == "__main__":
tornado.options.define("frequency", type=int)
tornado.options.parse_command_line()
for line in sys.stdin:
if not line:
continue
try:
n, extra = line.strip().split(" ", 1)
if int(n) > tornado.options.options.frequency:
sys.stdout.write(line)
except:
logging.exception('error reading line %r', line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment