I can use the following command to print all changed file and content in the stdout
rg --passthru -F "red" -r "green" -N
Output:
ip.txt
blue test1
green 2
hello blue world
ip2.txt
blue test1
green 2
hello blue world
ip3.txt
green test1
green 2
hello green world
ip4.txt
green test1
green 2
hello green world
how to write these files with changed content to the original file.