Skip to content

Instantly share code, notes, and snippets.

@jehiah
Created May 9, 2018 00:54
Embed
What would you like to do?
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