我在bash使用SED尝试替换匹配的所有字符串:文件全部替换字符串,使用通配符的替代
compile 'com.test.*:*'
有:
compile 'com.test.*:+'
其中*是一个通配符。
我的文件是这样的,这就是所谓的moo.txt:
compile 'com.test.common:4.0.1'
compile 'com.test.streaming:5.0.10'
compile 'com.test.ui:1.0.7'
,我希望它看起来像这样:
compile 'com.test.common:+'
compile 'com.test.streaming:+'
compile 'com.test.ui:+'
我试图用sed,如:
sed -i -- "s/compile \'com.test.*:.*\'/compile \'com.test.*:+\'/g" moo.txt
但是这使得文件的样子:
compile 'com.test.*:+'
compile 'com.test.*:+'
compile 'com.test.*:+'
任何想法如何在替代字段中正确使用通配符?
查找捕获组。 – 123