[英]How to Move all files within a single directory to multiple directories?
I have a directory that contains files I need from a calculation (6.00-film2) and I have 10 other directories, each with 10 sub-directories that I would like these files copied into. 我有一个目录,其中包含我需要的计算文件(6.00-film2),我有10个其他目录,每个目录有10个子目录,我希望这些文件被复制到。 Is there an easier way of doing this rather than doing 是否有更简单的方法来做而不是做
cp -r 6.00-film2/ 5.5-film/5.5-1
100 times. 100次。
The directory 5.5-film contains 5.5-1, 5.5-2, 5.5-3, 5.5-4, 5.5-5, ..., 5.5-10. 目录5.5-film包含5.5-1,5.5-2,5.5-3,5.5-4,5.5-5,......,5.5-10。 I need the files from 6.00-film2 to be copied into each of the 10 directories above, how would I go about doing that? 我需要将6.00-film2中的文件复制到上面的10个目录中的每个目录中,我将如何去做?
cp
can copy from multiple sources, but can't copy to multiple destinations. cp
可以从多个源复制,但不能复制到多个目标。 See man cp
for more info. 有关更多信息,请参阅man cp
。
The only bash command that I know which can copy/save to multiple destinations is tee
. 我知道唯一可以复制/保存到多个目的地的bash命令是tee
。
You can use it as follows: 您可以按如下方式使用它:
tee ~/folder1/test.txt ~/folder2/test.txt < ~/test.txt
Note that tee
also writes the input to the standard output (stdout). 请注意, tee
还将输入写入标准输出(stdout)。 So if you don't want this, you can prevent it by redirecting standard output to /dev/null
as follow: 因此,如果您不想这样,可以通过将标准输出重定向到/dev/null
来阻止它,如下所示:
tee ~/folder1/test.txt ~/folder2/test.txt < ~/test.txt >/dev/null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.