你想查的是哪种系统/环境下的“所有软连接(符号链接,symlink)”?下面按常见场景给你方法:
find /path/to/dir -type l
示例(查整个系统,谨慎使用):
find / -type l 2>/dev/null
2>/dev/null用于忽略权限不足的错误
ls -l /path/to/symlink
或
readlink /path/to/symlink
find /path -type l -lname "*target*"
find /path -type l ! -exec test -e {} \; -print
或(GNU find):
find /path -xtype l
Get-ChildItem -Path C:\ -Recurse -Force -ErrorAction SilentlyContinue |
Where-Object { $_.LinkType -eq "SymbolicLink" }
SymbolicLink(软连接)Junction(目录 junction)HardLink(硬链接)import os
for root, dirs, files in os.walk("/path"):
for name in files + dirs:
path = os.path.join(root, name)
if os.path.islink(path):
print(path)
如果你告诉我:
系统 + 具体目的 我可以给你更精确的命令。