Sed is very very powerful, which is a good thing to be aware of.
I was looking to compare the output of a sed command to the original file before I wanted to execute the sed command directly on the file and came across this handy trick.
It works by using temporary named pipes inside the diff command.
Contents of file:
One Two Three Four Five
If I just want to remove the line which begins with “Four”, I can check my sed command like this:
joris@beanie ~ $ diff <(sed '/Four/d' numbers.txt) numbers.txt 3a4 > Four
Awesome possum, now I know my sed command won’t destroy anything.