I've got the following shell command:

$ ex +'/>\zs\w\+\ze</p' -scq! /dev/stdin <<<$"foo>bar<buzz"

however it's matching the whole line, instead of the pattern.

How can I print only the matching pattern (bar)?

1 Answer 1


try :

ex +'s/.*>\(\w\+\)<.*/\1/|p' -scq! /dev/stdin <<<$"foo>bar<buzz"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.