sed: unterminated 's' command`

会有一股神秘感。 提交于 2019-11-27 08:24:47

问题


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

However it is giving: sed: -e expression #1, char 49: unterminated 's' command

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

What am I missing?


回答1:


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.



来源:https://stackoverflow.com/questions/36495793/sed-unterminated-s-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!