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
sed -n '/\.foo$/ { s/file/blag/; p }'
is more difficult to follow thansed -e'/\.foo$/!d' -e's/file/blag/'
But you still have the upvote. – Evan Carroll Jul 22 '18 at 17:24