Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

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

share|improve this question

marked as duplicate by jasonwryan, Bernhard, Anthon, Zelda, Thomas Nyman Jan 9 at 8:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
and it will especially show the the entire contents of all hidden directories ... –  Bananguin Jan 9 at 7:59
    
@Bananguin, indeed, I've updated my answer to take that into account. –  zagrimsan Jan 9 at 8:07
    
whereas ls -d .[^.]* does what you intended it to do ... –  Bananguin Jan 9 at 8:34

Here is one way to do it:

ls -dAF .* | egrep -v '/$'
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.