I have this:
(gc "$env:a.txt") -replace 'aaa', 'bbb'
I want to pipe it someway so it’ll print the lines that were changed (after the change), and only them (without simply searching for 'bbb', of course..). How ?
Edit:
I forgot to mention that I want to change the file in the process, which makes it harder (but I want to see, as a "sanity feedback", only the updated lines):
(gc "a.txt") -replace 'aaa', 'bbb' | something-here-?? | sc a.txt
Do I have to do that in two steps or there’s a way to pipe them all ?
For what you want, to show what is being changed and replace content of file, you can do:
If you just want to see diff after replacing, you can use
compare-object