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 and BBB are paths, and so contain ‘/’. AAA is fixed, so I can say:
sed s/\\\/A\\\/A\\\A/BBB/ file
However, BBB is based on variables, including $PWD. How do I escape the ‘/’ in $PWD?
OR is there some other way I should be doing this entirely?
sedcan use any separator instead of/in thescommand. Just use something that is not encountered in your paths:and so on.
Alternatively (and if you don’t want to guess), you can pre-process your path with sed to escape the slashes:
and then do what you need with
$pwdesc.