#!/bin/csh foreach i ($argv) if (! (-ef $i)) then echo "${0}: $i not a regular file" exit 1 endif end set f = `mktemp` foreach i ($argv) echo "" >> $f # make the file path absolute set n = $i echo "$n" | grep -q "^/" if ($status == 1) then set n = cwd/$i endif # easy part: remove all the single dots: replace /(./)* with / set n = `echo "$n" | sed s/\(\/\.\)*\//\//g` # hard part: removing all .. need to loop in case they are adjacent @ needmore = 0 while ($needmore == 1) echo "$n" | grep -q -v "/../" @ needmore = $status if ($needmore == 1) then set n = `echo "$n" | sed 's/\/[^/]*\/\.\.\//\//1'` # subtle case: /.. == / set n = `echo "$n" | sed 's/^\/\.\.\//\//1'` end end echo "===== $n =====" > $f cat $i >> $f end cat $f | mail $user -s "files: $argv:gt" rm $f