[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to only show symbol link with ls?
From: |
Bob Proulx |
Subject: |
Re: How to only show symbol link with ls? |
Date: |
Sat, 20 Feb 2010 15:01:45 -0700 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Peng Yu wrote:
> I don't see an option to list only symbolic link with ls. Could
> somebody let me know if there is such an option?
I don't quite understand the nature of your question. 'ls' lists
files in directories. There aren't specific options to 'ls' to only
list files of certain types. For example there isn't a way to only
have 'ls' list out named pipes, or just directories, or just character
devices, and so on. That isn't its job.
If you want to traverse a directory structure and select files based
upon specific attributes then you should use 'find' for this. For
example to list out only symbolic links use something like this:
$ ln -s bar foo
$ find . -maxdepth 1 -type l -print
./foo
Almost any particular format can be produced using find's -printf with
the appropriate format specification.
Of course you can also pipe the output of 'ls' to a filter and select
based upon the strings. I often do this.
$ ls -Clog | grep ^l
lrwxrwxrwx 1 3 2010-02-20 14:56 foo -> bar
$ ls -Clog | grep ^d
drwxr-xr-x 6 4096 2008-03-26 06:30 Maildir/
Bob