LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Make ls ignore symlinks (https://www.linuxquestions.org/questions/linux-software-2/make-ls-ignore-symlinks-137763/)

Creep 01-23-2004 07:45 AM

Make ls exclude symlinks
 
I'm trying to find a way to do 'ls -la' without a bunch of symlinks showing up in the directory listing. The reason is that my home-directory has a bunch of dotfiles symlinked to another directory, and when I type 'ls -la' to see the dotfiles which are not symlinked, the listing is cluttered by a bunch of nasty-looking symlinks. I tried piping ls's output a sed-script and some grepping here and there, but I couldn't find a good way to do it. If anyone of you knows of a simpler way to do it (such as an internal ls-flag :) ), I'd really appreciate it. Thanks.

Nis 01-23-2004 09:13 AM

Check out 'man ls'. I can't do it right now (I'm forced to used a Win Box here) but I remember there is a way to filter what is output.

Creep 01-23-2004 04:28 PM

I forgot to mention that I spend an hour and a half reading the manpage of ls trying different things here and there. I didn't find any useful information to solve my problem there though. Thanks for trying to help anyway.

mikshaw 01-23-2004 05:21 PM

Code:

ls -p | grep -v @
If you want to get it back to displaying columns:
Code:

ls -p | grep -v @ | column
By the way, this will ignore any file including a "@", so there may be a better way.

jwmt 06-11-2020 08:36 PM

If you are using `ls -l` and want to display the file info rather than the link info, just change to `ls -lL`. From `man ls`:
Quote:

-L, --dereference . when showing file information for a symbolic link, show information for the file the link references rather than for the link itself


All times are GMT -5. The time now is 08:38 PM.