I would like to change the following stringallow ^120\.123\.178\.254$into allow ^124\.130\.23\.235$with sed.I tried the following but it does not work.sed -e 's/allow ^120\.123\.178\.254$/allow ^124\.130\.23\.235$/g' /etc/xxx/file.confMay you can help me?
Change String with Sed
sed
Your source has \, $, ^ and . characters in them, which will need additional quoting.  Also your target has \ which should be quotedSo the resulting string is a little messy:sed 's/allow \^120\\\.123\\\.178\\\.254\$/allow ^124\\.130\\.23\\.235$/'The final g you had is only necessary if this string may appear multiple times per line.For example:$ cat xallow ^120\.123\.178\.254$$ sed 's/allow \^120\\\.123\\\.178\\\.254\$/allow ^124\\.130\\.23\\.235$/' x allow ^124\.130\.23\.235$