简体   繁体   English

如何将单个目录中的所有文件移动到多个目录?

[英]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.

相关问题 将多个目录中的文件复制到一个目录中 - Copy files within multiple directories to one directory 将多个文件移动到 linux 中的目录 - Move multiple files to directories in linux 在linux中,我怎样才能把zip具体的子目录改成自己的zip文件名,把父目录名和Z78E6221F6393D1356DZF2Z文件全部改成a393D1356DZF21的单目录? - In linux, how can I zip specific sub directories into their own zip files named parent directory name and output them all into a single directory? 使用 snakemake 处理多个目录和所有文件 - Process multiple directories and all files within using snakemake 如何使用 grep 提取目录和子目录中所有文件中包含的所有 IP 地址? - How can I use grep to extract all IP addresses contained in all the files within a directory and sub-directories? 将多个文件移动到多个目录 - Move multiple files to multiple to multiple directories 如何在多个不同目录中移动许多文件(在Linux上) - How to move many files in multiple different directories (on Linux) 如何在从多个目录/文件编译内核模块的同时创建新目录并向其中移动.o文件 - How to create new directories and move .o files to it while compiling a kernel module from multiple directories/files 在Linux脚本中,如何删除当前目录中的所有文件和目录? - In a Linux script, how to remove all files & directories but one, in current directory? Linux:如何删除目录本身(不是子目录)内的所有文件(不是目录) - Linux: How to delete all of the files (not directories) inside a directory itself (not childs)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM