替换" localhost"在使用sed的文本文件中

时间:2012-06-24 22:11:23

标签: sed memcached port

我有这样的文件,我想使用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;
?>

1 个答案:

答案 0 :(得分:2)

sed -i '/SERVER_MEMCACHED/s/localhost/mydomain.com/' input