只需在sed命令的外部使用双引号即可。$ sed "s/ones/one's/" <<< 'ones thing'one's thing它也适用于文件。$ echo 'ones thing' > testfile$ sed -i "s/ones/one's/" testfile$ cat testfileone's thing如果字符串中有单引号和双引号,也可以。只是转义双引号。例如,此文件包含带单引号和双引号的字符串。我将使用sed添加单引号并删除一些双引号。$ cat testfile"it's more than ones thing"$ sed -i "s/\"it's more than ones thing\"/it's more than one's thing/" testfile $ cat testfile it's more than one's thing