Search code examples
stringbashsedgrep

How to use sed/grep to extract text between two words?


I am trying to output a string that contains everything between two words of a string:

input:

"Here is a String"

output:

"is a"

Using:

sed -n '/Here/,/String/p'

includes the endpoints, but I don't want to include them.


Solution

  • sed -e 's/Here\(.*\)String/\1/'