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. C++(STL)&&树-堆结构练习——合并果子之哈夫曼树

    题目题解:http://blog.csdn.net/xu12110501127/article/details/9199335 有关博客:http://www.360doc.com/content/1 ...

  2. Andrew Ng-ML-第十三章-支持向量机

    1.从代价函数谈起SVM 图一 根据将y=0||y=1,得到逻辑回归的代价函数,那么SVM和其代价函数是相似的,只不过是引入了cost0与cost1,并且自变量使用了theta_T*x(i),并且由于 ...

  3. [LeetCode] 345. Reverse Vowels of a String_Easy tag:Two Pointers

    Write a function that takes a string as input and reverse only the vowels of a string. Example 1: In ...

  4. [LeetCode] 496. Next Greater Element I_Easy tag: Stack

    You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n ...

  5. java多态性方法的重写Overriding和重载Overloading详解

    java多态性方法的重写Overriding和重载Overloading详解 方法的重写Overriding和重载Overloading是Java多态性的不同表现.重写Overriding是父类与子类 ...

  6. 软件包管理:yum在线管理-yum命令

    只要我们的电脑可以接入互联网,那么yum源就是配好的,yum命令可以直接使用. 列出的是服务器上全部的rpm包. 包名,包全名的概念只在rpm手动管理时有用. 关键字主要指包名,只要知道了关键字就可以 ...

  7. MySQL实现SQL Server排名函数

    最近在MySQL中遇到分组排序查询时,突然发现MySQL中没有row_number() over(partition by colname)这样的分组排序.并且由于MySQL中没有类似于SQL Ser ...

  8. PAT乙级 1024. 科学计数法 (20)(未通过全部测试,得分18)

    1024. 科学计数法 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 HOU, Qiming 科学计数法是科学家用来表示很 ...

  9. python 的math模块

    数学模块用法:import math# 或 from math import * 变量 描述 math.e 自然对数的底e math.pi 圆周率pi 函数名 描述 math.ceil(x) 对x向上 ...

  10. python 采坑总结 调用键盘事件后导致键盘失灵的可能原因

    在练习python封装键盘事件的时候,实现一个keyDown和keyUp的功能: @staticmethod    def keyDown(keyName):        #按下按键        ...