List hidden files only
List hidden files only with ls -d .[!.]* in GNU coreutils 9 or any POSIX shell. The glob skips the dot and double dot entries that .* would match.
You want the dotfiles in a directory and nothing else, without the two special entries every directory has.
mkdir demo && cd demo
touch .env .gitignore ..odd visible.txt
ls -d .[!.]*
echo ---
ls -d .*.env
.gitignore
---
..odd
.env
.gitignoreThe glob .[!.]* means a dot, one character that is not a dot, then anything, so it skips . and .. in every shell. The -d option from GNU ls stops it listing the contents of any matching directory. The plain .* pattern is shorter, and Bash 5.2 turns on globskipdots so it drops the two special entries too, as the second list shows.
Before Bash 5.2, and in dash and zsh, .* also matches . and .., so the plain pattern is not portable. A name that starts with two dots, like ..odd, is missed by .[!.]*. Add ..?* as a second pattern if you need those. ls -A lists everything except the two special entries.