Skip to main content

text/sumsizes.py

1#!/usr/bin/env python3
2"""
3Given a list of numbers on stdin, add them together and print the result
4as a human-readable data size.
6Example:
8 echo -e '100 \n 201287 \n 3190817' | sumsizes
10"""
12import sys
14import humanize
17if __name__ == "__main__":
18 total = sum(int(line) for line in sys.stdin.readlines())
20 print(humanize.naturalsize(total))