GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   another boring unix question (https://gfy.com/showthread.php?t=438909)

Zester 03-02-2005 07:37 AM

another boring unix question
 
ok, you had it coming:

how do I list symbolic links and only (symbolic links) in a certain folder?
can't find the paramater for it with the "ls" command.

Zester 03-02-2005 07:44 AM

oh i forgot
need to show the symbolic link and the place it points to like so:
King -> mykingfolder
Lear -> mylearfolder

anyone?

maddox 03-02-2005 08:19 AM

try ls -al, otherwise if you want to list only symbolic links use find command

psili 03-02-2005 08:32 AM

ls -al | grep '^l'

?

Zester 03-02-2005 11:17 AM

I got this to list me the symbolic links:
find . -type -l

SplitInfinity 03-02-2005 12:13 PM

Just type this in your directory that you are in:

ls -la|grep ^l

SplitInfinity 03-02-2005 12:14 PM

Note that the ^l is ^ Ellllllll not pipe or eye or etc.

SplitInfinity 03-02-2005 12:14 PM

Jesters-Computer:~ chris$ ls -la|grep ^l
lrwxr-xr-x 1 chris chris 5 2 Mar 11:05 temp -> /home

Workshop_Willy 03-02-2005 12:18 PM

ls -l | grep \> | grep "lr"

this does a long listing and greps on ">" which indicates a link. As an added filter, you can pipe that output to another grep "lr" which are the first two characters of the permissions string on a symbolic link. This will insure that you have only symbolic links in the output.

This will only work on the current directory, as piping 'find' to 'ls' doesn't work. To search subdirectories, try this series of commands:
-------------------------------------------------

shellprompt$ ls -l|grep "drw"|awk '{print "ls -l "$9" | grep \\> | grep \"lr\""}' > linksearch

shellprompt$ . linksearch

-----------------------------------------------
You could put the above in an executable script and run it from anywhere.

I'm sure there are even better ways to do this. find . -name "*" -l n will work so long as you know the exact number of links a given file has, and has the advantage of walking an entire hierarchy.

I hope this helps.

willow 03-02-2005 12:21 PM

find . -maxdepth 1 -type l

Thats 1 as in one, and the l as in Link. So I agree with Zester.


All times are GMT -7. The time now is 10:45 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123