import argparse import os from time import sleep def main(): args = get_args() buckets = {} with open(args.p, "r") as f: f.seek(0, os.SEEK_END) while True: line = f.readline().strip() key = line.strip("/") if not line: sleep(0.25) continue if not key in buckets: buckets[key] = False buckets[key] = line[0] != "/" print(sorted([int(i) for i in buckets if buckets[i]])) def get_args(): ap = argparse.ArgumentParser() ap.add_argument("-p", type=str, help="path to write out to", default="/tmp/cbappend.both.txt") return ap.parse_args() if __name__ == "__main__": main()