sed:未终止的"s"命令 [英] sed: unterminated 's' command`
本文介绍了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}
我想念什么?
推荐答案
已解决:当我手动将变量$ 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屋!
查看全文