bash 中 sed 未终止的 s 命令出错 [英] Error with sed unterminated s command in bash

查看:22
本文介绍了bash 中 sed 未终止的 s 命令出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 bash 脚本中使用 sed 时遇到问题.这是行:

I'm having a problem with using sed in a bash script. Here is the line:

sed -i "s/"$name"/"$input"/g" ~/input.script

我收到此错误:sed:-e 表达式 #1,字符 24:未终止的 `s' 命令

I'm getting this error: sed: -e expression #1, char 24: unterminated `s' command

奇怪的是,它可以在我的代码的早期版本中运行.我一直在解决问题,但找不到解决方案.

Weirdly enough it was working in an earlier version of my code. I've been trouble shooting but I cannot find a solution.

推荐答案

您不需要嵌套引号.另外,尝试更改分隔符:

You don't need nested quotes. Also, try changing the delimeter:

sed -i "s@$name@$input@g" ~/input.script

这篇关于bash 中 sed 未终止的 s 命令出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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