I need to use the output of a command as a search pattern in sed. I will make an example using echo, but assume that can be a more complicated command:
echo
You need to tell xargs what to replace with the -I switch - it doesn't seem to know about the {} automatically, at least in some versions.
echo "pattern" | xargs -I '{}' sed -i 's/{}/replacement/g' file.txt