#!/bin/bash sed 's/[a-z]//g' | \ tee >(cut -c 1 > /tmp/firstdigits) | \ tee >(rev | cut -c 1 > /tmp/seconddigits) > /dev/null | \ paste - /tmp/firstdigits /tmp/seconddigits -d "" | \ paste -sd+ | \ bc