this is my script,

for i in `find . -type d -printf '%P\n'`;do
fulldir=`pwd`/$i
pbs=`find . -type f -name *.pbs -printf '%P\n'`
currentdir=`pwd`
rep=`grep 'cd /cs/data/arm129/' $i/*.pbs`
echo ""
tput smso
echo "full directory path is $fulldir"
echo "current path in pbs = $rep"
tput rmso

sed 's/$rep/cd $fulldir/gc' $i/*.pbs #problem here

tput smso
echo "the pbs path is now = `grep 'cd /cs/data/arm129/' $i/*.pbs`"
tput rmso
done

the problem is in the sed command. What I'm trying to do is change the path in all pbs files within a directory to the full path of that directory.

i.e

a.pbs is in data/arm1/hello

currently a.pbs contains
"cd data/arm1"

I want it to have
"cd data/arm1/hello"

The sed command is the only part of the script that does not work, does anyone know why? I think its because theres a directory as a pattern string and that contains "/", but I dont know how to get around this problem. Thanks