1.xargs Copying files
The file structure in the directory is:
. ├──demo1│ ├──test.lua│ ├──test.php│ └──test.txt└──demo2
Execute command:
Find./demo1/-name ' test* ' |cp ' xargs './demo2/
The directory structure is:
. ├──demo1│ ├──test.lua│ ├──test.php│ └──test.txt└──demo2 ├──test.lua ├──test.php
2.xargs Copying files
[Email protected] xargstest]# tree.├──demo1│ ├──test.lua│ ├──test.php│ └──test.txt└──demo2 ├── Test.lua ├──test.php └──test.txtfind./demo1/-name ' test* ' |xargs-i cp {} {}.bak.├──demo1│ ├── test.lua│ ├──test.lua.bak│ ├──test.php│ ├──test.php.bak│ ├──test.txt│ └── Test.txt.bak└──demo2 ├──test.lua ├──test.php └──test.txt
3.xargs Deleting files
Query for files ending with. bak
Find./demo1/-name ' *.bak '
./demo1/test.txt.bak./demo1/test.lua.bak./demo1/test.php.bak
Delete these files
Find./demo1/-name ' *.bak ' |xargs rm-fr
[Email protected] xargstest]# tree.├──demo1│ ├──test.lua│ ├──test.php│ └──test.txt└──demo2 ├── Test.lua ├──test.php └──test.txt
Delete Succeeded
Xargs Command Learning