1

I've got the following shell command:

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

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

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

2

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, privacy policy and cookie policy

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