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.

I want to list all hidden files and directories and then save result to file.

Is there any command for this?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

If using GNU find, you can do

find /path -path '*/.*' -ls | tee output-file

Edit

To avoid to show non-hidden items contained in hidden directories

find /path -name '.*' >output-file

(as noted, tee could be avoided if you do not need to see the output, and -ls option should be used only if required).

share|improve this answer
1  
Or with >instead of | tee, if one doesn't want to see the whole output on the terminal. –  rozcietrzewiacz Aug 7 '11 at 13:25
    
You also don't need -ls on this, that might be extra messy information to parse thought. –  Caleb Aug 7 '11 at 17:03
    
This also lists the contents of hidden directories, which isn't what the question asks for (probably — it is a little ambiguous). –  Gilles Aug 7 '11 at 19:53
    
@Gilles: indeed it is ambiguous. Edited the answer –  enzotib Aug 7 '11 at 20:00
add comment

To list the hidden files and directories in the current directory, including . and ..:

echo .*

To list the hidden files and directories in the current directory and its subdirectories recursively:

find . -name '.*'

If you want to save the results to a file, use a redirection:

find . -name '.*' >output-file.txt
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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