sed:未终止的“s"命令 [英] sed: unterminated 's' command`

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

问题描述

我正在编写一个不错的正则表达式来替换文本文件中的一些 IP.

I'm writing a nice regex to replace some IP's in a text file.

sed -r "s/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/${APP_IP}/g" /path/to/my/file

然而它给出:sed: -e expression #1, char 49: unterminated 's' command

我需要双引号,否则它会用文字变量名替换所需的字符串:${APP_IP}

I need the double quotes otherwise it replaces desired strings with the literal variable name: ${APP_IP}

我错过了什么?

推荐答案

SOLVED:当我手动将变量 $APP_IP 设置为被测 IP 时似乎有效.如果我从(ping 的)输出中捕获变量,它会给出错误.必须是变量中的特殊字符.谢谢各位.

SOLVED: Seems to be working when I set the variable $APP_IP manually to the IP under test. If I capture the variable from the output (of a ping) it gives the error. Must be special characters in the variable. Thanks guys.

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

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