Search code examples
linuxbashawksedash

How to extract string between 2 xml tags?


I have a string like this

<anytag>my message</anytag>

How I can extract the message between the tags with sed or awk? So I get only "my message"


Solution

  • sed 's/<.*>\(.*\)<\/.*>/\1/g' file