Operating System - Linux
1829608 Members
1395 Online
109992 Solutions
New Discussion

Re: how to display or find only softlink

 
SOLVED
Go to solution
Gemini_2
Regular Advisor

how to display or find only softlink

How do I list or find only softlinks in a directory?

if I do "ls -l", it will find both :-(
10 REPLIES 10
Sundar_7
Honored Contributor

Re: how to display or find only softlink

ls -l | grep "^l"
Learn What to do ,How to do and more importantly When to do ?
Ivan Ferreira
Honored Contributor

Re: how to display or find only softlink

You can use ls -l |grep ^l, and you can also use find ./* -prune -type l -ls
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Jeff Schussele
Honored Contributor

Re: how to display or find only softlink

Hi,

You can use find

find . -type l

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
TwoProc
Honored Contributor

Re: how to display or find only softlink

find . -type l -exec ls -al {} \;
We are the people our parents warned us about --Jimmy Buffett
Gemini_2
Regular Advisor

Re: how to display or find only softlink

thank you all. in my case, I had "->"
so I had to use "\->", that did the trick..


I wish there is a way to display the softlink differently

like right now, it is

softlink real-link

so I have to reverse it to be
real-link softlink when I use "ln -s real-link softare" to recreate some of the softlinks...
James R. Ferguson
Acclaimed Contributor
Solution

Re: how to display or find only softlink

Hi Gemubu:

Here's an eary way to output the linkage relationship in reverse notation:

# find . -type l | xargs ls -l | awk '{print $NF,$(NF-2)}'

Regards!

...JRF...
Gemini_2
Regular Advisor

Re: how to display or find only softlink

excellent!!!

that is exactly what I want!!!

thank you soo much

I assigned points to everyone..

you guys are the bEST!!!
James R. Ferguson
Acclaimed Contributor

Re: how to display or find only softlink

Hi (again) Gemini:

Sorry for the typo spelling your name.

If you prefer, add the 'ln -s' to your output, too:

# find /var -type l | xargs ls -l | awk '{print "ln -s",$NF,$(NF-2)}'

Regards!

...JRF...
Gemini_2
Regular Advisor

Re: how to display or find only softlink

yes..yes..I see what you meant..

too beautiful!!

thanks again!!! million times!!!

Nguyen Anh Tien
Honored Contributor

Re: how to display or find only softlink

James R. Ferguson is nice solution,
I agree with him!
Just comment that "-type l" mean search all link file.
Enjoy with scripting
tienna
HP is simple