sed plus sign doesn't work

后端 未结 4 1450
你的背包
你的背包 2020-12-01 15:53

I\'m trying to replace /./ or /././ or /./././ to / only in bash script. I\'ve managed to create regex for sed but it doe

4条回答
  •  执念已碎
    2020-12-01 16:08

    Use -r option to make sed to use extended regular expression:

    $ variable="something/./././"
    $ echo $variable | sed -r "s/\/(\.\/)+/\//g"
    something/
    

提交回复
热议问题