sed string between two patterns code example
Example 1: sed between two patterns
Just use following structure to get result between two different patterns:
sed -n '/^pattern1/,/^pattern2/p;/^pattern2/q' file.txt
Example 2: sed get substring between two characters
echo "Here is a string" | grep -o -P '(?<=Here).*(?=string)'