【发布时间】:2019-03-29 11:18:02
【问题描述】:
我的目标是替换(就地)任何
的实例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
我不确定这个错误是什么意思...希望有人能提供帮助!
【问题讨论】:
-
我只想就地编辑文件。我不想创建备份。我应该如何修改它以使其工作?
-
你不需要创建任何备份,在
-i之后添加''。见stackoverflow.com/a/14813278/3832970 -
还是不行。 sed -i'' 's/src=\"*.+http/src=\"http/g' pathto/test.html 仍然失败。
-
你读过那个帖子吗?至少有 3 个选项可以做到这一点。
标签: macos sed applescript