#!/bin/bash
s='xyzblahxyzxyzblahxyzxyzblahblahxyz'
perl -pe 's/xyz(.*?)xyz/<$1>/g' <<< "$s"