How to do a find & replace on text files?

I've searched the forums and Google extensively. I want to find & replace a certain text string inside a markdown file, every time it is saved. So I'm using "date last modified" (less than 1 min) as a trigger, and I think I have to use a script to do the find & replace bit. I've tried the script
But that returns
I tried to add an exit code of 0, and that removes the error, but it has no result. I tried a variation where it creates a new file:
That does create a new file, but it's empty. I tried the same thing an hour ago, and that did work, but it only copied the line with the replaced string, not the rest of the file. I can't reproduce that now.
Can anyone help me out?
- Code: Select all
sed -i -e 's/old_string/new_string/g' $1
But that returns
- Code: Select all
Error] Shell script failed: Error processing shell script
I tried to add an exit code of 0, and that removes the error, but it has no result. I tried a variation where it creates a new file:
- Code: Select all
sed -n 's/old_string/new_string/gpw newfile.md' $1
exit 0
That does create a new file, but it's empty. I tried the same thing an hour ago, and that did work, but it only copied the line with the replaced string, not the rest of the file. I can't reproduce that now.
Can anyone help me out?