如何在 AppleScript 中使用 sed 来 find/replace html 文件中的所有实例?

How to use sed inside AppleScript to find/replace all instances in an html file?

我的目标是替换(就地)

的任何实例
src="[random text i want to remove]http

src="http

在 html 文件中。问题:我需要使用 AppleScript 来执行此操作。代码如下:

set myfile to "pathto/test.html"

do shell script "sed -i 's/src=\"*.+http/src=\"http/g' " & quoted form of myfile

这给出了错误:

sed: 1: "pathto/test.html": command c expects \ followed by text

我不确定这个错误是什么意思...希望有人能帮忙!

这有效:

sed -i '' -E 's/src=\"*.+http/src=\"http/g' myfile.html

-i 后必须有一个space。