shell 替换

#!/bin/bash
test=$HOME/test.xml
sed -e '/^<port>.*>$/c  <port>8080</port>' $test >test1.xml

替换



cd $HOME/dpf_home/cfg
    echo "cat smsagent.cfg"
     cat smsagent.cfg | grep "<port"

    sms_cfg=$HOME/dpf_home/cfg/smsagent.cfg
    randomPort=`echo "$RANDOM+5000" | bc`
    echo $randomPort
    sed -e "s/<port>.*<\/port>/<port>$randomPort<\/port>/" ${sms_cfg} >smsagent.cfg_bak
    mv smsagent.cfg_bak smsagent.cfg
    echo ok
    cat smsagent.cfg | grep "<port"

你可能感兴趣的:(C++,c,xml,C#,bash)