link 个目录中的文件,使用类似于 cp 的简单命令

link files within directory, with simple command similar to cp

我的问题来源:

问题:

我会使用 find "$PWD/source" -exec ln -s {} destination \;。用作 find 的第一个参数的绝对路径将导致 {} 被替换为每个命令的源文件的绝对路径。

GNU ln 支持 -t 选项来指定目标目录,允许您更有效地调用 find:

find "$PWD/source" -exec ln -s -t destination {} +

-exec ... +形式要求{}是命令中的最后一个参数; -t 允许您向上移动目标参数以满足该要求。

所以我最终找到了一种简单的方法来做到这一点:

简直运行ln -s $(pwd -P)/source/* destination/