-3

I am searching here in stack but all the answers are only for those who only has a particular caps. What I want is a word/s in all caps.

For example: Abby ABBY aBbY SNOOPY doll

The output must be: ABBY SNOOPY

J.Doe
  • 59
  • 9

1 Answers1

2

If you're using GNU grep, it has a PCRE option that includes \b to match word boundaries. In between you match only capital letters.

grep -P -o '\b[A-Z]+\b' filename

The -o option makes it print only the parts of the line that match the regexp.

Barmar
  • 596,455
  • 48
  • 393
  • 495