bash script
我试图制作一个列出目录中所有符号链接文件的脚本,但 im 使用的命令似乎在脚本中不起作用,但当我在终端中使用它时有效。
结果
您可以尝试这些选项,看看最适合您需求的选项。
伪代码:
#!/usr/bin/bash
find . -type l -ls
#To only process the current directory:
#find . -maxdepth 1 -type l -ls
更多查找命令以在 dir 中列出符号链接:
find -L /dir/to/start -xtype l -samefile ~/Pictures 2>/dev/null.
find / -lname /path/to/original/dir
- L - 遵循符号链接。
- xtype l - 文件是符号链接
- 相同文件名 - 文件引用与名称相同的索引节点。当 -L 生效时,这可以包括符号链接。