I can use ls -ld */
to list all the directory entries in the current directory. Is there a similarly easy way to just list all the regular files in the current directory? I know I can use find
find . -maxdepth 1 -type f
or stat
stat -c "%F %n" * | grep "regular file" | cut -d' ' -f 3-
but these do not strike me as being overly elegant. Is there a nice short way to list only the regular files (I don't care about devices, pipes, etc.) but not the sub-directories of the current directory? Listing symbolic links as well would be a plus, but is not a necessity.
Best Answer
With
zsh
and Glob Qualifiers you can easily express it directly, e.g:will either only return the list of regular files or an error depending on your configuration.
For the non-directories:
(will include symlinks (including to directories), named pipes, devices, sockets, doors...)
for regular files and symlinks to regular files.
for non-directories and no symlinks to directories either.
Also, see the
D
globbing qualifier if you want to include Dot files (hidden files), like*(D-.)
.