display only files starting with . (hidden)
ls -ld .*
will do what you want.
find . -type f -name '\.*' -print
Must work if you want list every hidden file down in the directory hierarchy.
If you want to parse ls
output, you must add ^
at beginning of regex and don't use -l
option. Using -l
causes each line output start with file or folder permission information, not file or folder name. So you should use like this:
ls -Ad | grep '^\.'
Or you can do with printf
bash builtin:
printf "%s\n" .*
If you use zsh
, you can use:
print -l .*