I have a text file that contain a lot of mess text.
I used grep to get all the text that contains the string prod like this
cat textfile | grep "<host>prod*" The result
<host>prod-reverse-proxy01</host> <host>prod-reverse-proxy01</host> <host>prod-reverse-proxy01</host> Continually, i used sed with the intention to remove all the "host" part
cat textfile | grep "<host>prod*" | sed "s/<host>//g"; "s/</host>//g" But only the first "host" was removed.
prod-reverse-proxy01</host> prod-reverse-proxy01</host> prod-reverse-proxy01</host> How can i remove the other "/host" part?
sed "s/<host>//g"; "s/</host>//g". Pipe to another invocation of sed. Also see Multiple replacements with one sed command, Join multiple sed commands in one script for processing CSV file, etc.sed -E '/<host>prod/ s|</?host>||g' ip.txtorsed -nE '/<host>prod/ s|</?host>||gp' ip.txtdepending on what you need... also, don't use double quotes unless you need it