qq674949301
V2EX  ›  问与答

关于 sed 替换带有双引号的值

  •  
  •   qq674949301 · Dec 20, 2015 · 2768 views
    This topic created in 3822 days ago, the information mentioned may be changed or developed.
    #!/bin/sh
    
    
    ENABLED=yes
    PROCS=pddd
    ARGS="-c /opt/etc/config.json"
    PREARGS=""
    DESC=$PROCS PATH=/opt/sbin:/opt/bin:/opt/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    

    想把该脚本中ARGS="-c /opt/etc/config.json"替换成ARGS="-c /opt/etc/config_1.json"

    请各位帮帮忙,写了几个 sed 命令都无法替换成功!在线等!

    4 replies    2015-12-20 20:08:16 +08:00
    darkshell
        1
    darkshell  
       Dec 20, 2015
    ```
    sed -i 's/"-c \/opt\/etc\/config.json"/"-c \/opt\/etc\/config_1.json"/g' a.sh
    ```
    qq674949301
        2
    qq674949301  
    OP
       Dec 20, 2015
    @darkshell 无效!直接变成 ARGS=" "!
    qq674949301
        3
    qq674949301  
    OP
       Dec 20, 2015
    @darkshell sed -e 's/ARGS="-c \/opt\/etc\/config.json"/ARGS="-c \/opt\/etc\/config_1.json"/g' /mnt/sda3/S22shadowsocks
    这样就可以了,谢谢你的指导!
    darkshell
        4
    darkshell  
       Dec 20, 2015
    @qq674949301 哦哦哦.. 那就好.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   897 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 19:41 · PVG 03:41 · LAX 12:41 · JFK 15:41
    ♥ Do have faith in what you're doing.