Example : use find lookup /data Under the directory , with .txt File at the end of the file and copy to /tmp lower

Method 1

find And |xargs It's a golden partner ,-t Parameter specifies the target directory , Using pipes for replication
[root@centos ~]# ls /tmp [root@centos ~]# find /date/ -type f -name "*.txt" |
xargs cp -t /tmp [root@centos ~]# ls /tmp 1.txt [root@centos ~]#
Method 2

{} The content in braces is find Results found by command
[root@centos ~]# ls /tmp [root@centos ~]# find /date/ -type f -name "*.txt"
-exec cp {} /tmp \; [root@centos ~]# ls /tmp 1.txt [root@centos ~]#
Method 3

$()=`` Store the execution result of the command
[root@centos ~]# ls /tmp [root@centos ~]# cp $(find /date/ -type f -name
"*.txt") /tmp [root@centos ~]# ls /tmp 1.txt [root@centos ~]#
Method 4

-i Parameter specifies that the found results are placed in {} in , Using pipes to achieve
[root@centos ~]# ls /tmp [root@centos ~]# find /date/ -type f -name "*.txt" |
xargs -i cp {} /tmp [root@centos ~]# ls /tmp 1.txt [root@centos ~]#
summary : The above four methods can be achieved find Command and cp Combined use of commands , You can choose one of them according to your own needs in life and work . If it helps you , Hope to support .

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?