What's the command line equivalent of: For every file that contains "AAA" within its contents, find "BBB" and replace it with "CCC"
Thus, the command would match and replace BBB in a file:
<html>
<head></head>
<body>
AAA
Hello world!
BBB    
</body>
</html>
But Not in a开发者_开发技巧 file:
<html>
<head></head>
<body>
Don't match me!
BBB    
</body>
</html>
Thanks in advance!
Something like grep -l AAA file-names | xargs sed -i .bak 's/BBB/CCC/g' should work.  In the future, you might want to ask questions like this on https://serverfault.com/ instead.
Using positive look behind also can do the trick s/(?<=AAA).*?(BBB)/CCC/g.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论