How to recursively list all hidden files and directories

directoryfiles

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

Is there any command for this?

Best Answer

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).