Using sed and grep/egrep to search and replace

前端 未结 6 835
小鲜肉
小鲜肉 2020-11-30 16:47

I am using egrep -R followed by a regular expression containing about 10 unions, so like: .jpg | .png | .gif etc. This works well, now I would like

6条回答
  •  忘掉有多难
    2020-11-30 17:23

    Another way to do this

    find . -name *.xml -exec sed -i "s/4.6.0-SNAPSHOT/5.0.0-SNAPSHOT/" {} \;
    

    Some help regarding the above command

    The find will do the find for you on the current directory indicated by .

    -name the name of the file in my case its pom.xml can give wild cards.

    -exec execute

    sed stream editor

    -i ignore case

    s is for substitute

    /4.6.0.../ String to be searched

    /5.0.0.../ String to be replaced

提交回复
热议问题