You cannot have matching matches. "BAR PIPPO" was not detected because "BAR" is already consumed when matching "FOO BAR".
FOO BAR PIPPO PLUTO 31337 1010
------- ===========
1 2
Try this instead:
$ sed -re 's/ ([A-Z])/-\1/g'
Note that this does not have matching matches:
FOO BAR PIPPO PLUTO 31337 1010
-- == --
1 2 3
source
share