I would like to find all words that all all uppercase, but when I do
grep -oP '\w*[A-Z]+\w*' *
I get
words.py:StringValue
words.py:WORDS
words.py:WORDS_ANSWERED
words.py:Answered
words.py:True
where I were hoping for
words.py:WORDS
words.py:WORDS_ANSWERED
Question
How can I make sure that only all uppercase words is outputted?
You can use this regex with word boundary on either side and by using [A-Z0-9_]
instead of \w
:
grep -H -oP '\b[A-Z0-9_]*[A-Z]+[A-Z0-9_]*\b' *
words.py:WORDS
words.py:WORDS_ANSWERED
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With