Reputation: 13
I'm looking to search through a line where I must indicate the 3rd and 4th characters should not be lowercase. This is what I have so far however, I'm not sure how to indicate both characters in one line of code.
ls grep | $...[!a-z].$....[!a-z]
Upvotes: 1
Views: 19
Reputation: 6721
Try this. I did the following and it worked for me.
ls | grep -e '^..[^a-z][^a-z].*$'
Example:
mkdir abcD abcd abcde abCD ABCD ABcd abCDe
ls | grep -e '^..[^a-z][^a-z].*$'
When I executed the above commands, I go the following output:
$ ls | grep -e '^..[^a-z][^a-z].*$'
ABCD
abCD
abCDe
$
You are trying to restrict lower case using [!a-z]
. You should use [^a-z]
for this purpose.
Hope this helps.
Upvotes: 0
Reputation: 53535
Solution:
grep -e '^..[^a-z][^a-z].*$' test.txt
test.txt:
abaXYom
abCdef
ghIJkl
lalalolo papa
234234234
OUTPUT:
ghIJkl
234234234
Upvotes: 1