#!/bin/csh if ($#argv != 2) then echo "Error: improper arguments to chngdocclass:" echo "$1" "$2" "$3" exit else set olddocclass = "\documentclass\[.*\]{.*}" set newdocclass = "$1" set file = $2 set nlines_found = `grep -c "$olddocclass" $file` # grep option -c == count set savstat = $status if ($savstat != 1) then sed s/"$olddocclass"/"$newdocclass"/g $file > sed.out if ($status == 0) then echo "Changing file $file" echo " Replaced pattern -> $olddocclass" mv sed.out $file else echo " Error parsing sed command.\c" echo " No changes made." exit endif endif echo " with new string -> $newdocclass" endif