Seker:

find . -name "*" |xargs cp ????

这里 xargs cp 怎么区分cp源 和 cp目的 
例如:想把 查询到的文件 都copy到/home/users/中去
        find . -name "*" | xargs cp /home/users/
cp命令在这里就变成:cp /home/users/ Find_file

默认从管道传来的值是放在最后的 这样的话原本想做cp源文件的值和目的目录的参数就颠倒了
有办法解决一下吗?
xargs 没有想-exec 那种 {} 的变量吗?

davistar:

find . -name "*" | xargs -i cp {}  /home/users/

nuclearxin:

-i 和{} 什么关系?

davistar:

-i 表示 find 传递给xargs的结果 由{}来代替

--------------------------------------------------------------

在Ubuntu (Ubuntu 12.04.4 LTS \n \l)上查到的结果:

-I replace-str
              Replace occurrences of replace-str in the initial-arguments with names read from standard input.  Also, unquoted blanks do not terminate input items; instead the separator is  the  new‐
              line character.  Implies -x and -L 1.

--replace[=replace-str]
       -i[replace-str]
              This option is a synonym for -Ireplace-str if replace-str is specified, and for -I{} otherwise.  This option is deprecated; use -I instead.

[user@host:pkg]$ find -type f | grep -v orig | grep -v tmp |xargs grep -l 'cp -rp' | xargs cp tmp2
cp: target `./mkpkg.sh' is not a directory
[user@host:pkg]$ cd tmp2
[user@host:tmp2]$ ls
[user@host:tmp2]$ cd ../
[user@host:pkg]$ find -type f | grep -v orig | grep -v tmp |xargs grep -l 'cp -rp' | xargs cp {} tmp2
cp: target `./mkpkg.sh' is not a directory
[user@host:pkg]$ find -type f | grep -v orig | grep -v tmp |xargs grep -l 'cp -rp' | xargs -i cp {} tmp2
[user@host:pkg]$ cd tmp2
[user@host:tmp2]$ ls
i

关于xargs cp中,如何确定拷贝的源和目的 (copied)的更多相关文章

  1. 关于xargs cp中,如何确定拷贝的源和目的

    来源: http://bbs.chinaunix.net/thread-1022095-1-1.html Seker: find . -name "*" |xargs cp ??? ...

  2. find + xargs + cp 遇到文件名中带空格如何处理

    一,需求为查询文件名为ZRSH开头的时间为7月至今的所有文件并打包 1.首先想到的就是find + xargs + cp  格式.. find 2016073* -type f  -name *ZRS ...

  3. docker中,将容器中的文件拷贝到宿主机上

    需求说明: 今天在做docker修改配置文件的问题,一个容器要使用另外容器的一个配置文件,但是在宿主机上没有, 就考虑将容器中的文件拷贝到宿主机上,在此记录下操作过程. 操作过程: 1.通过docke ...

  4. 【转载】C++中的位拷贝和值拷贝

    ---恢复内容开始--- 原文:C++中的位拷贝和值拷贝 原文:http://blog.csdn.net/liam1122/article/details/1966617 为了便于说明我们以Strin ...

  5. Linux 中的零拷贝技术,第 2 部分

    技术实现 本系列由两篇文章组成,介绍了当前用于 Linux 操作系统上的几种零拷贝技术,简单描述了各种零拷贝技术的实现,以及它们的特点和适用场景.第一部分主要介绍了一些零拷贝技术的相关背景知识,简要概 ...

  6. Linux 中的零拷贝技术,第 1 部分

    概述 本系列由两篇文章组成,介绍了当前用于 Linux 操作系统上的几种零拷贝技术,简单描述了各种零拷贝技术的实现,以及它们的特点和适用场景.本文是本系列文章的第一部分,主要是介绍一些零拷贝技术的相关 ...

  7. Path,Files巩固,题目:从键盘接收两个文件夹路径,把其中一个文件夹中(包含内容)拷贝到另一个文件夹中

    这个题目用传统的File,InputStream可以做,但是如果用Files,Path类做,虽然思路上会困难一些,但是代码简洁了很多,以下是代码: import java.io.IOException ...

  8. Media Player 把光盘中的内容拷贝出来的方法

    http://jingyan.baidu.com/article/cb5d610529f0c1005c2fe0b4.html  这个链接是通过Media  Player 把光盘中的内容拷贝出来的方法h ...

  9. Linux中的零拷贝技术

    转载:https://www.jianshu.com/p/fad3339e3448 引文## 在写一个服务端程序时(Web Server或者文件服务器),文件下载是一个基本功能.这时候服务端的任务是: ...

随机推荐

  1. 不需要更多JS框架了

    现在,JavaScript框架已成为Web项目开发不可或缺的一部分.那是因为很长一段时间以来,各种浏览器之间有很大的差别,人们不得不编写框架对此进行屏蔽.问题在于,各种浏览器甚至在基本问题上都难以取得 ...

  2. orm之路由层

    一.简单配置 1.参数 第一个参数是正则表达式(如果要精准匹配:‘^publish/$’),或者加斜杠('^publish/') 第二个参数是视图函数(不要加括号) urlpatterns = [ u ...

  3. [LeetCode] questions conclustion_Path in Tree

    Path in Tree: [LeetCode] 112. Path Sum_Easy tag: DFS       input: root, target,   return True if exi ...

  4. linux mail 发送邮件附件

    在很多场景中我们会使用Shell命令来发送邮件,而且我们还可能在邮件里面添加附件,本文将介绍使用Shell命令发送带附件邮件的几种方式,希望对大家有所帮助. 文章目录 1 使用mail命令 2 使用m ...

  5. [lr] 直方图

    直方图基础知识 • 直方图的特征和作用 ▪ 直方图的x轴从左到右代表亮度逐渐增加,即从最暗到最亮:y轴代表某个亮度值下颜色像素的多少(密度). ▪ 直方图由红绿蓝三种颜色组成,分别表示红绿蓝通道:其中 ...

  6. C# 定时器 一个简单 并且可以直接运行的Demo

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  7. AdaBoost Classifier和Regressor

    Adaboost原理传送门 AdaBoost在我看理论课程的时候,以分类为例子来讲解的,谁知道sklearn里面基本上都有classifier和regressor两种.这个倒是我没想到的!!! fro ...

  8. Lintcode: Insert Node in a Binary Search Tree

    Given a binary search tree and a new tree node, insert the node into the tree. You should keep the t ...

  9. python学习第一次

    一,安装python 官网下载地址:https://www.python.org/downloads/windows/ 我下载的是最新的: Download Windows x86 web-based ...

  10. 26最短路径之Floyd算法

    Floyd算法 思想:将n个顶点的图G“分成”很多子图 每对顶点vi和vj对应子图Gij(i=0,1,…,n-1和j=0,1,…,n-1) 每对顶点vi和vj都保留一条顶点限于子图Gij中的最短路径P ...