我的剧本

#!/bin/bash

for dir in $(/home/milenko/Documents/mt/MT8 -type d -maxdepth 1); do
cp -i kop.sh "$dir"/;
done

但是
p.sh: line 3: /home/milenko/Documents/mt/MT8: Is a directory

编辑
现在插入find
find /home/milenko/Documents/mt/MT8 -type d -maxdepth 1

找到了,没问题。我还是收到了警告
find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

为什么?

最佳答案

错误信息非常清楚,您提供的路径是指向目录的路径。根据你通过的论点,我认为你应该使用

find /home/milenko/Documents/mt/MT8 -type d -maxdepth 1

关于linux - 如何将文件复制到子目录?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33872018/

10-13 06:59