#!/usr/bin/env bash grep -Eo 'mul\([0-9]+,[0-9]+\)' input | sed -E 's/^mul\(([0-9]+),([0-9]+)\)/\1*\2/g' | bc | paste -s -d "+" | bc