How to remove all words written in capital letters ONLY (by using sed and/or awk)
- by Virtual_Lotos
I am trying to delete all words written in capital letters only by using sed:
sed -r "s/\b[A-Z]\w*\s*//g" < file1 > file2
But this solution capture all the words starting with capital letters and delete them (this in not the goal).
Here's an example:
file1 content:
AAAAAAAAAAAA
BBbbbbb
AbAbAbAb
aaaaaBBBBB
AAAAAA BBBBBB
A1-B1
a1-b1
A1-b1 AA
AAAAA BBBBB AAAAA
Abbbb AAA
AAAAA AAAABB
Abbbb Baaaa Aaaaa AB
AAAAAA1
BBBBBBb
AAAAAA 1
BBBBBB b
Result should be like this (file2 content):
BBbbbbb
AbAbAbAb
aaaaaBBBBB
A1-B1
a1-b1
A1-b1 AA
Abbbb AAA
Abbbb Baaaa Aaaaa AB
AAAAAA1
BBBBBBb
AAAAAA 1
BBBBBB b
Each line of at least one digit or one lowercase letter should remain intact (should not be deleted).