Convert echo/grep/tr/sed pipeline to single sed command
We can use the -n option of sed to limit output only to explicitly printed lines.
With a bit of quotation trickery, we can alter the sed command to include the argument file name in the substitution as well.