如何将ls的结果复制到指定的文件夹中

sh/bash/dash/ksh/zsh等Shell脚本
回复
whaha
帖子: 104
注册时间: 2016-07-08 17:43
系统: debian8

如何将ls的结果复制到指定的文件夹中

#1

帖子 whaha » 2016-12-24 19:02

ls /home/myphp
back_hand.php back_vps.php keep_eye.sh
back_qiniu.php back_weixin.php runTime.php


ls /home/myphp |xargs cp -r /tmp/test
cp: target ‘runTime.php’ is not a directory
头像
b33e
帖子: 3864
注册时间: 2011-06-07 14:20
系统: Mint18

Re: 如何将ls的结果复制到指定的文件夹中

#2

帖子 b33e » 2016-12-24 19:22

代码: 全选

ls /home/myphp |xargs -i cp -r /home/myphp/{}  /tmp/test
头像
lilydjwg
论坛版主
帖子: 4249
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: 如何将ls的结果复制到指定的文件夹中

#3

帖子 lilydjwg » 2016-12-24 19:38

代码: 全选

ls /home/myphp |xargs cp -r -t /tmp/test
回复