I want to get the list of subfolders with names in uppercase only (folder name only, without leading pardir
or tailing /
).
I tried find . -maxdepth 1 -type d -name '[A-Z] '
but it doesn't work.
CodePudding user response:
If you want upper-case names in Regex, use the [:upper:]
class name:
find . -maxdepth 1 -type d -regextype posix-extended -regex './[[:upper:]] '
Or using Bash's extglob
Extended Globbing:
shopt -s extglob
printf %s\\n ([[:upper:]])/
CodePudding user response:
The -name
operator does not use regular expressions as you might expect. Instead it using "wildcards" similar to the bash wildcard system as described here.
You probably want to use the -regex
operator as described in the Full Name Patterns section of the documentation. Using this you should have a command like:
find . -maxdepth 1 -regex '\./[A-Z] '
You can do any other path operations using the options described in the Run Commands section.