I have problem write grep which should grep only those lines, in which is word that consist only from capital characters.
For example I have file : file1.txt
Abc AAA
ADFSD
F
AAAAx
And output should be :
Abc AAA
ADFSD
F
Thank for any advice.
You can just use:
grep -E '\b[[:upper:]]+\b' file1.txt
That is, look for whole words composed of only uppercase letters.
This egrep should work:
egrep '\b[A-Z]+\b' file
This will produce the desired results,
egrep '\b[A-Z]+\b' file1.txt
Results are
Abc AAA
ADFSD
F
GNU grep supports POSIX patterns, so you can simply do:
grep -e '[[:upper:]]' file1.txt
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