use a different delimiter:
sed "s@TEMPDIR@$PWD@" file.py > newfile.py
Using PWD probably does not guarantee an absolute path. (Depends on the shell). But pwd
will return an absolute path, so use:
sed "s@TEMPDIR@$(pwd)@" file.py > newfile.py
Note that neither of these will work if your paths contain @
. Pick a delimiter that does not appear in either. Note the following from the shell standard:
In cases where PWD is set to the pathname that would be output by pwd -P, if there is insufficient permission on the current working directory, or on any parent of that directory, to determine what that pathname would be, the value of PWD is unspecified. Assignments to this variable may be ignored. If an application sets or unsets the value of PWD , the behaviors of the cd and pwd utilities are unspecified.
So you can probably rely on $PWD. Note that neither pwd
nor $PWD
will resolve symbolic links, so you might prefer to use readlink -f .