I try to replace some text in a file with the command sed from bash
I want to replace the line :
$app["gentle.root"] = "/home/doc/";
to
$app["gentle.root"] = "/home/exemple/";
I try :
sed -i's/$app["gentle.root"] = "/home/doc/";/$app["gentle.root"] = "/home/exemple/";' /home/martialp/Documents/default.php
But I'm getting this error
sed: -e expression n°1, caractère 7: commande inconnue: `m'
您应该转义特殊符号:
sed -i 's/\$app\[\"gentle.root\"\] = \"\/home\/doc\/\"\;/\$app\[\"gentle.root\"] = \"\/home\/exemple\/\"\;/' /home/martialp/Documents/default.php
从另一种角度考虑,如果替换行中包含“ /”,建议使用其他字符。
sed '/gentle.root/ s#/home/doc#/home/exemple#' file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.