Seems like this is rather simple, but I\'m having trouble.
I have a text document that looks, for example, like this:
This is a
TEXT DOCUME
The example output shows multiple space separated uppercase words on the same line, which can be achieved with
$ grep -ow '[[:upper:]][[:upper:][:space:]]*[[:upper:]]' infile
TEXT DOCUMENT
SOME
BUT NOT
ALL CAPS
Any sequence starting and ending with an uppercase character, and uppercase characters or whitespace between them. -o
returns the matches only, and -w
makes sure that we don't match something like WORDlowercase
.