I'm trying to use ls
in zsh (running on macOS) to show all files and directories except directories that begin with a capital letter.
For example, my directory contains
Archive/ data/ README.md test.txt
and I would like to run an ls
command that returns only
data/ README.md test.txt
I can use ls -d [A-Z]*/
(note the terminating backslash to indicate directories) to show the directories I want to hide (e.g. only returns Archive/
),
and referencing this helpful answer on using the inverted expansion in zsh with the ls *~
syntax,
I tried (what I think is) the negation of the above using ls -d *~[A-Z]*/
but this doesn't work (it hides nothing).
Moreover, using ls -d *~[A-Z]*
(without the terminating backslash) returns data/ test.txt
but this is not my desired result since I also want to show the file README.md
which begins with a capital letter.
Note that I have enabled the extended glob option in zsh, using setopt extendedglob
.
Any help on the correct regex/glob syntax for ls
in zsh to obtain my desired output would be very much appreciated. Thank you! :)
Edit: There are two very useful answers that work, but any concise answers using ls
in zsh (using the extended glob option) would still be awesome!