简体   繁体   English

在 Unix/Linux 中将特定文件从一个文件夹复制到另一个文件夹

[英]Copy specific files from one folder to another in Unix/Linux

I want to do a very similar thing than here .我想做一件与这里非常相似的事情。 The difference is that I want to copy only the files containing specific string in their name (eg file_00).不同之处在于我只想复制名称中包含特定字符串的文件(例如 file_00)。

Using the answer from this post , I tried this :使用这篇文章的答案,我尝试了这个:

cp -a /home/folder_1/. find . -name "*file_00*" - print /home/folder_2

But the function cp doesn't recognize the function find .但是函数 cp 不能识别函数find Then I tried然后我试过了

cp -a /home/yanncochet/folder_1/. -e'file_00' /home/yanncochet/folder_2

But same error message.但同样的错误信息。 Can anyone help ?任何人都可以帮忙吗?

find is a separate program from cp . find是一个独立于cp程序。 What I think you were trying to do was use find as input for cp.我认为您尝试做的是使用 find 作为 cp 的输入。 You can use command substitution for that:您可以为此使用命令替换

cp $(find directory/ -name "*file_00*") destination/

$(...) basically runs the command inside and returns it's output. $(...)基本上在里面运行命令并返回它的输出。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Linux中将以“ a”,“ c”或“ e”开头的前N个文件从一个文件夹复制到另一个文件夹 - Copy first N files which start with 'a' 'c' or 'e' from one folder to another in Linux Linux 在 bash/python 脚本中将下一个“n”个文件从一个文件夹复制到另一个文件夹 - Linux copy next 'n' number of files from one folder to another in bash/python script 如何在Linux / Unix中将多个文件从一个扩展名重命名为另一个扩展名? - How to rename multiple files from one extension to another in Linux / Unix? 将文件(特定扩展名)从文件夹结构复制到另一个文件夹 - Copy files (of specific extension) from a folder structure to another folder 从另一个文件夹linux shell中删除一个文件夹中的文件 - removing files which are in one folder from another folder linux shell 使用 Linux 将特定数量的文件从一个目录复制到另一个 - Copy specific number of files from on directory to another using Linux 如何在Linux中将具有特定扩展名的文件从一个目录复制到另一个目录 - How to copy files with a particular extension from one directory to another in linux 在linux中将文件列表从一个位置复制到另一个位置 - Copy list of files from one location to another in linux 在Linux中将文件从一个路径复制到另一路径 - copy files from one path to another path in linux 将文件夹结构(不含文件)从一个位置复制到另一个位置 - Copy folder structure (without files) from one location to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM