How can I use find to search for symbolic links?
This is what I have:
abc:~/findtests$ ls -l
total 0
lrwxrwxrwx 1 abc abc 2开发者_运维百科2 2010-11-30 14:32 link1 -> /home/abc/testpy1.py
I am trying to search for the link link1
in the current directory.
I did :
abc:~/findtests$ find -L . -lname 'link1'
abc:~/findtests$ find -P . -lname 'link1'
abc:~/findtests$ find -L . -lname 'test*'
abc:~/findtests$ find -P . -lname 'test*'
But could not get any output. What am I doing wrong ?
To start with, from the man page:
"Using -L causes the -lname and -ilname predicates always to return false."
The target of the symbolic link doesn't match 'test*' because there is the full path. Try '*/test*'.
How about find . -type l -name link1
?
Also, find . -lname '*test*'
seems to work for me.
"Using -L causes the -lname and -ilname predicates always to return false." says the find man page
so those two wouldn't work anyway
but is the problem to be solved to find a symlink via its target path or by its name as aix's answer does
精彩评论