I have a csh script (although I can change languages if it has any relevance) where I have to:
sed s/AAA/BBB/ file
The problem is that AAA
Using csh
for serious scripting is usually not recommended. However, that is tangential to the issue at hand.
You're probably after something like:
sed -e "s=$oldpath=$newpath="
where the shell variable $oldpath
contains the value to be replaced and $newpath
contains the replacement, and it is assumed that neither variable contains an equals sign. That is, you're allowed to choose the delimiter on pattern, and avoiding the usual /
delimiter avoids problems with slashes in pathnames. If you think =
might appear in your file names, choose something less likely to appear, such as control-A or control-G.