#!/bin/csh
#
# kedgr - recursive global string substitution on the subdirectories
# syntax: kedgr string1 string2 filenames
#
set allfiles = `ls`
set subfiles = `ls $argv[3-]`
set file =
foreach file ($subfiles)
	if( -f $file) then
ed $file <<!
1,\$s/$1/$2/g
w
!
	endif
end

foreach file ($allfiles)
	if( -d $file) then
		echo cd $file; cd $file; kedgr $argv[1-]; cd ..
	endif
end
