Bash – ls everything that is _not_ a symlink

bashlssymlink

Does ls have a way to show negated conditions like "all files which are not a symlink"? I use the latter a lot in a project directory but other negations would be useful as well.

For now, my research has only lead to creating an alias to something "like":

find . -maxdepth 1 ! -type l | sort # (...)

but obviously this way I don't get the colouring of ls, the column formatting, etc…

I am on Bash v3 on OS X 10.8.2 and Bash v4 on Pangolin sometimes.

Best Answer

Instead of piping it to sort, use ls.

find . -maxdepth 1 \! -type l -exec ls -d {} +

find . -maxdepth 1 \! -type l | xargs ls -d

If you used the zsh shell you could use their non-portable glob extensions:

ls -d *(^@)
Related Question