+ -
当前位置:首页 → 问答吧 → sed数据处理请教

sed数据处理请教

时间:2011-07-07

来源:互联网

# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#       allows crc checksumming etc.
service rsync
{
        disable = no
        socket_type  =    stream
        wait         =    no
        user         =    root
        server       =    /usr/bin/rsync
        server_args      --daemon
        log_on_failure  + USERID
}

disable = no 我想把它全局替换成disable = yes 该怎么写呢,我说的是全局,而不是指定第几行号替换

作者: ibelieveme   发布时间: 2011-07-07

本帖最后由 MaskRay 于 2011-07-07 12:38 编辑

ed file <<< $'s/disable\\(.*\\)=\\(.*\\)no/disable\1=\2yes/\nw'

code 吃 $ 的?

作者: MaskRay   发布时间: 2011-07-07

本帖最后由 南极雨 于 2011-07-07 13:14 编辑

回复 ibelieveme


sed 's/disable = no/disable = yes/g' file

作者: 南极雨   发布时间: 2011-07-07

回复 南极雨


    不行无法替换

作者: ibelieveme   发布时间: 2011-07-07

回复 ibelieveme


你指的不是这样的么?
  1. echo 'service rsync
  2. {
  3.         disable = no
  4.         socket_type  =    stream
  5.         wait         =    no
  6.         user         =    root
  7.         server       =    /usr/bin/rsync
  8.         server_args      --daemon
  9.         log_on_failure  + USERID
  10. }' |sed 's/disable = no/disable = yes/g'
  11. service rsync
  12. {
  13.         disable = yes
  14.         socket_type  =    stream
  15.         wait         =    no
  16.         user         =    root
  17.         server       =    /usr/bin/rsync
  18.         server_args      --daemon
  19.         log_on_failure  + USERID
  20. }
复制代码

作者: yinyuemi   发布时间: 2011-07-07