🔍 See Original Answer on Ask Ubuntu 🔗
How can I exclude . and .. when listing hidden items?
May 28, 2020
Edited: May 28, 2020
November 24, 2022
Copy to clipboard: false
From the second answer in:
This works on my machine (I’m not using SSH like the OP though):
ls -d .!(|.)
If there are no hidden files or directories you will get an error message:
$ ls -d .!(|.) ls: cannot access '.!(|.)': No such file or directory
The error message occurs on directories with no hidden files because
.. are excluded.
ls -d .[!.]* works without