#!/usr/bin/python3 ip_vol = {} import sys import re regexp = "^(\S+) (\S+) (\S+) \[([^]]+)\] \"(\w+) (\S+).*\" (\d+) (\S+)" for line in sys.stdin: # on lit sur l’entrée standard line = line.rstrip () # on enleve le retour ligne res = re.match (regexp, line) if res: (host, rfc931, user, date, request, url, status, byte) = res.groups() host = res.group (1) byte = res.group (8) if host in ip_vol: ip_vol[host] +=int(byte) else: ip_vol[host] = int(byte) for host in ip_vol.keys(): print(host, " ",ip_vol[host])