#!/bin/sh categories=$(( $(cat $1 | grep -oE '[0-9]*$' | wc -l ) - 1 )) grep -oE '[0-9]*$' $1 | head -n $categories | paste -sd+ | bc