Artificial intelligent assistant

Factoring a grep out of a grep | sed stream or writing grep in sed? I have a file like: file.foo file2.foo file.bar file3.foo Now I want to return only lines that end with `.foo`, but I want to rename all occurrences of `file` with `blag`. In this case that means skipping over `file.bar` entirely. How do I go about doing it **with just sed**? Essentially what I'm doing currently is: grep '\.foo$' input | sed -e's/file/blag/' But I would like to cut the grep out. This question is roughly based on a pipeline I made for this answer

I was able to get `grep` out of my pipeline to `sed` by using `!d`


sed -e'/\.foo$/!d' -e's/file/blag/' ./input


Answer sourced from this forum post

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy c436f11e620998af13dc5d171e12ffe4