Replace text using sed

后端 未结 3 532
再見小時候
再見小時候 2021-01-24 17:43

i am having trouble replacing the modified date in my script via sed.

I am getting the last modified date like this:

olddate=`grep -m1 \"Built \" script.         


        
相关标签:
3条回答
  • 2021-01-24 18:06

    use sed "s#$olddate#$newdate#g"

    that should work

    0 讨论(0)
  • 2021-01-24 18:18

    Use , instead of / !

    sed -i "" "s,$olddate,$newdate,g" script.sh
    

    In fact you can use almost any char as separators.

    0 讨论(0)
  • 2021-01-24 18:27

    You can use separators other than slashes, for instance ";"

    sed -i "" "s;$olddate;$newdate;g" script.sh
    
    0 讨论(0)
提交回复
热议问题