Is there a way to filter a directory listing to only show symbolic links?
don’t know if it’s waterproof, but I just do a ’ ls -al | grep .-> ’
That seems to work…
I understand everything up to the .-> portion…
Does the grep command just look for the → character? Is that what you’re doing?
Is there a way to show just the opposite? Everything BUT the symbolic links?
You could for example take a look at the man page for grep. I will give you a hint. Search for the -v option.
Excellent…
Thanks for the hint.
The > is a special symbol (redirect). So thats why the slash () is in front of it to indicate it should be read as normal character. The dot basically does the same to not let grep interpret the - as an option switch.
So basically you filter the ls output with grep to only show lines containing -> , indicating a link. As the > cannot be used as file character it should only return links.
Quick and dirty
Hope that clarifies it,
Wj
That clarifies it.
Thanks.
I found that
ls -al | grep “^l”
also works to do the same job.
That probably is the official way
outsider787 wrote:
> Is there a way to filter a directory listing to only show symbolic
> links?
>
>
find ./ -maxdepth 1 -type l -print0 | xargs -0 ls -l
On Thu, 03 Jul 2008 16:06:03 GMT
outsider787 <outsider787@no-mx.forums.opensuse.org> wrote:
>
>Is there a way to filter a directory listing to only show symbolic
>links?
>
I have this function in my .alias file (in my home directory):
function showsym {
ls -la $@ | egrep “^^-dpst]”
}
along with all my favorite aliases. Then, in the .bashrc file I call it
like this:
test -s ~/.alias && . ~/.alias || true
so it is loaded when bash starts . . .
–
Kevin Nathan (Arizona, USA)
Linux is not a destination, it’s a journey – enjoy the trip!
Linux 2.6.22.18-0.2-default
6:21pm up 13:59, 21 users, load average: 0.42, 0.50, 0.60
Topic has been moved to the Application forum.
On Fri, 04 Jul 2008 01:56:03 GMT
69 rs ss <69_rs_ss@no-mx.forums.opensuse.org> wrote:
>
>Topic has been moved to the Application forum.
>
>
Thanks! Guess I need to add that one, too.
–
Kevin Nathan (Arizona, USA)
Linux is not a destination, it’s a journey – enjoy the trip!
Linux 2.6.22.18-0.2-default
7:46pm up 15:25, 21 users, load average: 0.24, 0.40, 0.42
On Thu, 03 Jul 2008 19:46:04 GMT
Magic31 <Magic31@no-mx.forums.opensuse.org> wrote:
>
>outsider787;1832151 Wrote:
>>
>> I found that
>> ls -al | grep “^l”
>> also works to do the same job.
>That probably is the official way
>
>
If you make that an alias (for less typing) it will only work if you
are in the directory – it won’t work if you want a listing from a
different directory. For that, I have this function in my .alias file
(in my home directory):
function showsym {
ls -la $@ | egrep “^l”
}
along with all my favorite aliases. Then, in the .bashrc file I call it
like this:
test -s ~/.alias && . ~/.alias || true
so it is loaded when bash starts . . .
(Actually, I use a little different grep expression, but that’s for
another discussion!)
–
Kevin Nathan (Arizona, USA)
Linux is not a destination, it’s a journey – enjoy the trip!
Linux 2.6.22.18-0.2-default
7:51pm up 15:30, 21 users, load average: 0.33, 0.47, 0.45
Of course it does, but the important thing is: do you know why?