1

I am trying to automate some scripts and need to change the paths of files one of the scripts reads to do the automation.

Because these paths have special characters, I am hitting a wall. I have tried escaping the special characters but obviously I am doing sth wrong...

Here is what I have:

newpath="/media/g1/Enzymes@Work/MARENOSTRUM/PATHWAYS/COP/test1_A/"
sed -e "s/THISISTHEPATHTOTHEDIRECTORY/${newpath}/g" sampleTrajs.py

which gives me the expected error:

sed: -e expression #1, char 34: unknown option to `s'

fedorqui
  • 275,237
  • 103
  • 548
  • 598
gugy
  • 105
  • 11
  • 2
    Just use another sed separator: `sed -e "s|...|$newpath|g" file`. That is, use something that is not contained in the string you are changing. Otherwise, sed sees so many separators. – fedorqui Oct 27 '15 at 09:59
  • 1
    thanks, that works perfectly fine. did not know sed can work with other separators :P – gugy Oct 27 '15 at 10:07

0 Answers0