Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 递归复制用户可执行文件_Bash - Fatal编程技术网

Bash 递归复制用户可执行文件

Bash 递归复制用户可执行文件,bash,Bash,如何递归地将文件夹中的所有用户可执行文件复制到另一个文件夹 比如说,我有 在文件夹文件夹/one中: -rwxrwxr-x 1 user group 7777777 Jun 1 12:00 executable1 -rw-rw-r-- 1 user group 4444 Jun 1 12:00 text1.txt 在文件夹文件夹/two中: -rwxrwxr-x 1 user group 7777777 Jun 1 12:00 executable2 -rw-rw-r-- 1 us

如何递归地将文件夹中的所有用户可执行文件复制到另一个文件夹

比如说,我有

在文件夹
文件夹/one
中:

-rwxrwxr-x 1 user group 7777777 Jun  1 12:00 executable1
-rw-rw-r-- 1 user group    4444 Jun  1 12:00 text1.txt
在文件夹
文件夹/two
中:

-rwxrwxr-x 1 user group 7777777 Jun  1 12:00 executable2
-rw-rw-r-- 1 user group    4444 Jun  1 12:00 text2.txt
它应该只递归地将
可执行文件1
可执行文件2
文件夹
复制到目标文件夹,而不保留原始层次结构

目标文件夹应具有:

-rwxrwxr-x 1 user group 7777777 Jun  1 12:00 executable2
-rwxrwxr-x 1 user group 7777777 Jun  1 12:00 executable1

您可以使用find命令:

 find folder -type f -executable -exec echo "{}" /tmp \;

验证输出是否正确后,用
cp-p
替换
echo

OP需要
cp-p
。谢谢!这正是我想要的。如果你在和一棵大树打交道,你应该替换它+编码>或使用
xargs
来节省时间,只运行一个
cp
(如果有很多可执行文件,可能会分解为多个)