How do I select all hidden files in a directory? ls .*
selects the current folder - .
, as well as it's parent ..
. I just want the hidden files
Asked
Active
Viewed 1,647 times
2 Answers
5
ls .[^.]*
will show you all entries that start with a dot and are followed by a non-dot character, thus skipping both current (since it has only the leading dot, nothing following that) and parent directories. It will also show the content of hidden directories, and if that is not wanted, ls -d .[^.]*
will omit the contents of hidden folders.
If you only want the hidden files in the current directory, find . -maxdepth 1 -type f -name ".*"
will do exactly that.

zagrimsan
- 766
ls -d .[^.]*
does what you intended it to do ... – Bananguin Jan 09 '14 at 08:34*
is not a quantifier applied to[^.]
like in a regular expression, but the bash syntax for "anything" instead. – giorgiosironi Oct 06 '16 at 10:57