I have a string that I want to remplace in a script to put the actual path of the file so: my issue is that the string has special characters inside
Dir=pwd
old=simulationfoam = OpenFOAMReader(registrationName='simulation.foam', FileName='path/simulation.foam')
new=simulationfoam = OpenFOAMReader(registrationName='simulation.foam', FileName='${Dir}/simulation.foam')
My first attend was to signle quote everything:
old='simulationfoam = OpenFOAMReader(registrationName='simulation.foam', FileName='path/simulation.foam')'
new='simulationfoam = OpenFOAMReader(registrationName='simulation.foam', FileName='${Dir}/simulation.foam')'
but the issue persisted after looking in the web i found this :https://stackoverflow.com/questions/15783701/which-characters-need-to-be-escaped-when-using-bash where it mentionned that I should scape the ' with 'backslash' so I remplace the internal ' of the string with 'backslash''