sed: -e 表达式 #1, char 23: `s' 的未知选项 [英] sed: -e expression #1, char 23: unknown option to `s'

查看:75
本文介绍了sed: -e 表达式 #1, char 23: `s' 的未知选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 sed 来使用 bash 脚本更新配置文件.我在运行良好的脚本中的这个命令上方有一个类似的 sed 命令.我似乎无法弄清楚为什么会这样:

I'm trying to use sed to update a config file using a bash script. I have a similar sed command right above this one in the script that runs fine. I can't seem to figure out why this is breaking:

sed -i.bak \
    -e s/"socketPath:'https://localhost:9091'"/"socketPath:'/socket'"/g \
    $WEB_CONF

有什么想法吗?

推荐答案

引号和双引号导致问题.鉴于字符串中的斜杠,您正在使用它们.在 sed 中,您可以使用另一个分隔符,例如 #.

The quotes and double quotes are causing problems. You are using them in view of the slashes in the string. In sed you can use another delimiter, such as a #.

sed -e 's#socketPath:https://localhost:9091#socketPath:/socket#g' \
$WEB_CONF

这篇关于sed: -e 表达式 #1, char 23: `s' 的未知选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆