小编Isa*_*aac的帖子

为什么“cp”在与“find”链接时抱怨相同的文件?

我有一个find如下的命令列出了匹配的文件:

$ find . -type f -name "*.txt"

./level2/file2.txt
./level2/level3/file3.txt
./level2/level3/level4/file4.txt
./level2/level3/level4/level5/file5.txt
./output.txt
Run Code Online (Sandbox Code Playgroud)

现在我尝试通过链接将每个列出的文件复制到特定文件夹exec

$ ls copy_here | wc -l
0

$ find . -type f -name "*.txt" -exec cp {} ./copy_here \;
cp: ./copy_here/file2.txt and ./copy_here/file2.txt are identical (not copied).
cp: ./copy_here/file3.txt and ./copy_here/file3.txt are identical (not copied).
cp: ./copy_here/file4.txt and ./copy_here/file4.txt are identical (not copied).
cp: ./copy_here/file5.txt and ./copy_here/file5.txt are identical (not copied).
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助分解执行顺序以帮助更好地理解执行流程吗?

command-line bash scripts find cp

7
推荐指数
1
解决办法
2042
查看次数

标签 统计

bash ×1

command-line ×1

cp ×1

find ×1

scripts ×1