1

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

Casebash
  • 1,051

2 Answers2

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
0

Here is one way to do it:

ls -dAF .* | egrep -v '/$'
cuonglm
  • 153,898