我有这样的文件,我想使用sed将$GLOBALS['SERVER_MEMCACHED']='localhost';
替换为$GLOBALS['SERVER_MEMCACHED']='mydomain.com';
。
怎么做?我也不想替换DB_HOST。
<?php
$GLOBALS['DB_HOST']='localhost';
$GLOBALS['DB_NAME']='database';
$GLOBALS['DB_LOGIN']='login';
$GLOBALS['DB_PASSWORD']='password';
$GLOBALS['PORT_MYSQL']='3306';
$GLOBALS['PORT_MYSQLI']='3306';
$GLOBALS['SERVER_MEMCACHED']='localhost';
$GLOBALS['PORT_MEMCACHED']='11211';
$GLOBALS['CACHE_TIME']=600;
?>
答案 0 :(得分:2)
sed -i '/SERVER_MEMCACHED/s/localhost/mydomain.com/' input