Esto recorrerá el /path/to/folderdirectorio de forma recursiva y enumerará solo los enlaces simbólicos:
ls -lR /path/to/folder | grep ^l
Si su intención es seguir también los enlaces simbólicos, debe usar su findcomando pero debe incluir la -Lopción; de hecho, la findpágina del manual dice:
-L Follow symbolic links. When find examines or prints information
about files, the information used shall be taken from the prop‐
erties of the file to which the link points, not from the link
itself (unless it is a broken symbolic link or find is unable to
examine the file to which the link points). Use of this option
implies -noleaf. If you later use the -P option, -noleaf will
still be in effect. If -L is in effect and find discovers a
symbolic link to a subdirectory during its search, the subdirec‐
tory pointed to by the symbolic link will be searched.
When the -L option is in effect, the -type predicate will always
match against the type of the file that a symbolic link points
to rather than the link itself (unless the symbolic link is bro‐
ken). Using -L causes the -lname and -ilname predicates always
to return false.
Entonces intente esto:
find -L /var/www/ -type l
Esto probablemente funcionará: encontré en la findpágina del manual este diamante: si está utilizando la -typeopción, debe cambiarla a la -xtypeopción:
l symbolic link; this is never true if the -L option or the
-follow option is in effect, unless the symbolic link is
broken. If you want to search for symbolic links when -L
is in effect, use -xtype.
Luego:
find -L /var/www/ -xtype l
find -L /var/www/ -xtype l). Usar en-xtypelugar de-typedebería hacer el truco en tu búsqueda. ¡Buena suerte!ls -laR /path/to/folder | grep ^lsi usted también quiere proceso "oculta" punto carpetas ...-xtypeno está disponible.find . -type lparece estar comprobando recursivamente.Un comando, sin tuberías
Explicación:
finddesde el directorio actual en.adelante, todas las referencias de-type ltinta y enumerarlas-lsen detalle. Llano y simple ...Ampliando esta respuesta, aquí hay un par más de
findcomandos relacionados con enlaces simbólicos :Encuentra enlaces simbólicos a un objetivo específico
Tenga en cuenta que
link_targetes un patrón que puede contener caracteres comodín.Encuentra enlaces simbólicos rotos
La
-Lopción le indicafindque siga enlaces simbólicos, a menos que esté roto.Encuentra y reemplaza enlaces simbólicos rotos
Más ejemplos de búsqueda
Se
findpueden encontrar más ejemplos aquí: https://hamwaves.com/find/fuente
findtienen una-lsopción. Entoncesfind . -type l -lsdebería ser el equivalente de lo anterior.find -lname '*/dir/*' -printf '%P -> %l\n'. Vale la pena mencionar que link_target es un patrón.findYa se ve de forma recursiva por defecto:fuente
findrepetimos por defecto? Supongo que no;)-Lbandera para encontrar sin suerte, ¿alguna conjetura?Para ver solo los enlaces simbólicos, puede usar
mientras que si desea ver también a qué archivos se dirigen, simplemente agregue un ls
fuente
Esto es lo mejor que he encontrado hasta ahora: le muestra los enlaces simbólicos en el directorio actual, recursivamente, pero sin seguirlos, que se muestran con rutas completas y otra información:
Las salidas se ven así:
fuente
Lo que hago es crear un script en mi directorio bin que es como un alias. Por ejemplo, tengo un script llamado lsd ls -l | grep ^ d
podrías hacer uno lsl ls -lR | grep ^ l
Simplemente modifícalos + x y listo.
fuente