TransWikia.com

ls everything that is _not_ a symlink

Unix & Linux Asked on December 20, 2020

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.

One 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 *(^@)

Correct answer by Random832 on December 20, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP