我有很多文件,我需要在某些字符串中将 ':' 替换为 ' -' 。
我用 grep 找到了我需要的所有字符串:grep -G '^ \* @' datapath/ -r
但现在我需要用'-'替换这个字符串中的所有':',我不知道怎么做。
请帮帮我。
最佳答案
看看sed命令。简而言之,您将像这样使用它:
for file in datapath/*.file; do
sed s/"^ \* @"/-/g $file > $file.new
done
关于ubuntu - 替换 grep 找到的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15199800/