regexshellfindglob

regex to exclude lowercase only strings, but save strings which contain capital


Look to those regex

find /tmp/MG/virt-manager-5.0.0/ -maxdepth 1 -type f |grep -v  [^a-z]+\.[^a-z]+
/tmp/MG/virt-manager-5.0.0/.mailmap
/tmp/MG/virt-manager-5.0.0/virt-manager
/tmp/MG/virt-manager-5.0.0/DESIGN.md
/tmp/MG/virt-manager-5.0.0/meson.build
/tmp/MG/virt-manager-5.0.0/NEWS.md
/tmp/MG/virt-manager-5.0.0/.gitignore
/tmp/MG/virt-manager-5.0.0/README.md
/tmp/MG/virt-manager-5.0.0/.pylintrc
/tmp/MG/virt-manager-5.0.0/.coveragerc
/tmp/MG/virt-manager-5.0.0/virt-install
/tmp/MG/virt-manager-5.0.0/.packit.yaml
/tmp/MG/virt-manager-5.0.0/COPYING
/tmp/MG/virt-manager-5.0.0/virt-xml
/tmp/MG/virt-manager-5.0.0/virt-manager.spec.in
/tmp/MG/virt-manager-5.0.0/INSTALL.md
/tmp/MG/virt-manager-5.0.0/meson_options.txt
/tmp/MG/virt-manager-5.0.0/virt-manager.spec
/tmp/MG/virt-manager-5.0.0/virt-clone
/tmp/MG/virt-manager-5.0.0/CONTRIBUTING.md
/tmp/MG/virt-manager-5.0.0/setup.cfg

I want to get strings which contain CAPITAL letters, including .md .txt but only if words contain at least one capital letter, to explain better

CONTRIBUTING.MD OK
CONTRIBUTING.txt OK
CONTRIBUTING.TXT OK
Contributing.txt OK (has one capital letter)
hello.TXT OK (contain some capital letters)
contributing.txt NO (only lowercase)

I want to obtain this

  find /tmp/MG/virt-manager-5.0.0/ -maxdepth 1 -type f |grep -v REGEXWORKS

    /tmp/MG/virt-manager-5.0.0/DESIGN.md
    /tmp/MG/virt-manager-5.0.0/NEWS.md
    /tmp/MG/virt-manager-5.0.0/README.md
    /tmp/MG/virt-manager-5.0.0/COPYING
    /tmp/MG/virt-manager-5.0.0/INSTALL.md
    /tmp/MG/virt-manager-5.0.0/CONTRIBUTING.md

how to do? Thanks


Solution

  • With awk and a regex:

    find . -type f | awk -F'/' '$NF ~ "[[:upper:]]"'