#!/bin/sh if [ $# -eq 0 ]; then echo "usage: sumpoints []" echo " must have the following structure: name \":\" points for exercises, separated by commas." exit 1 fi # names: sed -e 's/:.*$/: /' $1 > ~/misc/pipe1& # total points: sed -e 's/^.*:[[:space:]]*//' -e 'y/,-/+0/' $1 | bc -l > ~/misc/pipe2& # percentage of maximum: if [ -n "$2" ]; then ( echo "scale=2"; sed -e 's/^.*:[[:space:]]*/(/' -e 'y/,-/+0/' -e 's|$|)*100/'$2'|' $1) | bc -l > ~/misc/pipe3& paste ~/misc/pipe1 ~/misc/pipe2 ~/misc/pipe3 else paste ~/misc/pipe1 ~/misc/pipe2 fi