ls everything that is _not_ a symlink
5,641
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 videos on Youtube
Author by
JohnyMoraes
Updated on September 18, 2022Comments
-
JohnyMoraes almost 2 years
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.
-
Admin over 3 years
-
-
JohnyMoraes almost 12 yearsThx 4 the answer! Why do you escape !? It seems to be working even without.. What I am risking by not escaping it? Interesting how you use a final
+
and not\;
, please explain? -
Random832 almost 12 years@Robottinosino The
+
makes it send all to a singlels
command instead of running it separately for each file (this way ls can do the columns and sorting). I escaped the ! because it is a special character to some shells even though yours seems to accept it fine. -
Random832 almost 12 years@Robottinosino Edited with something zsh can do. I don't think bash can do it though.