#!/bin/tcsh -f @ err = 0 foreach com (`ls | grep "\.txt" | cut -d . -f 1`) source $com.txt | diff $com.out - set err_ = $? if ($err_) then echo "$com -> $err_ [FAIL]" else echo "$com -> $err_" endif @ err = $err + $err_ end if ($err) then echo "Something went wrong! (Sum of error codes: $err)" else echo "All works fine!" endif