关于xargs cp中,如何确定拷贝的源和目的
来源:
http://bbs.chinaunix.net/thread-1022095-1-1.html
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 那种 {} 的变量吗?
find . -name "*" | xargs -i cp {} /home/users/
-i 和{} 什么关系?
-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中,如何确定拷贝的源和目的的更多相关文章
- 关于xargs cp中,如何确定拷贝的源和目的 (copied)
Seker: find . -name "*" |xargs cp ???? 这里 xargs cp 怎么区分cp源 和 cp目的 例如:想把 查询到的文件 都copy到/home ...
- find + xargs + cp 遇到文件名中带空格如何处理
一,需求为查询文件名为ZRSH开头的时间为7月至今的所有文件并打包 1.首先想到的就是find + xargs + cp 格式.. find 2016073* -type f -name *ZRS ...
- docker中,将容器中的文件拷贝到宿主机上
需求说明: 今天在做docker修改配置文件的问题,一个容器要使用另外容器的一个配置文件,但是在宿主机上没有, 就考虑将容器中的文件拷贝到宿主机上,在此记录下操作过程. 操作过程: 1.通过docke ...
- 【转载】C++中的位拷贝和值拷贝
---恢复内容开始--- 原文:C++中的位拷贝和值拷贝 原文:http://blog.csdn.net/liam1122/article/details/1966617 为了便于说明我们以Strin ...
- Linux 中的零拷贝技术,第 2 部分
技术实现 本系列由两篇文章组成,介绍了当前用于 Linux 操作系统上的几种零拷贝技术,简单描述了各种零拷贝技术的实现,以及它们的特点和适用场景.第一部分主要介绍了一些零拷贝技术的相关背景知识,简要概 ...
- Linux 中的零拷贝技术,第 1 部分
概述 本系列由两篇文章组成,介绍了当前用于 Linux 操作系统上的几种零拷贝技术,简单描述了各种零拷贝技术的实现,以及它们的特点和适用场景.本文是本系列文章的第一部分,主要是介绍一些零拷贝技术的相关 ...
- Path,Files巩固,题目:从键盘接收两个文件夹路径,把其中一个文件夹中(包含内容)拷贝到另一个文件夹中
这个题目用传统的File,InputStream可以做,但是如果用Files,Path类做,虽然思路上会困难一些,但是代码简洁了很多,以下是代码: import java.io.IOException ...
- Media Player 把光盘中的内容拷贝出来的方法
http://jingyan.baidu.com/article/cb5d610529f0c1005c2fe0b4.html 这个链接是通过Media Player 把光盘中的内容拷贝出来的方法h ...
- Linux中的零拷贝技术
转载:https://www.jianshu.com/p/fad3339e3448 引文## 在写一个服务端程序时(Web Server或者文件服务器),文件下载是一个基本功能.这时候服务端的任务是: ...
随机推荐
- ASP.Net初级学习一(基本语句入门)
<body > <form method="post" action="program.ashx"> <input type=&q ...
- uboot启动原理
1.裸机运行程序时一般情况下程序代码小于16KB将其下载地址设置到BL1的起始地址.BL0会自动加载并执行BL1. 当程序大于16kB时无法直接运行. 例如UBOOT就大于16KB,执行的原理为.将程 ...
- try catch finally 和return
结论:1.不管有木有出现异常,finally块中代码都会执行:2.当try和catch中有return时,finally仍然会执行:3.finally是在return后面的表达式运算后执行的(此时并没 ...
- 使用localhost调试本地代码,setcookie无效
今天在本地调试代码的时候,再域名中使用localhost,结果一直调试不成功,最后发现在登录时,setcookie()没有设置进去 于是发现了,在使用localhost调试时,保存cookie是无效的 ...
- MySQL和Postgresql的区别
一.PostgreSQL相对于MySQL的优势 1.在SQL的标准实现上要比MySQL完善,而且功能实现比较严谨:2.存储过程的功能支持要比MySQL好,具备本地缓存执行计划的能力:3.对表连接支持较 ...
- Jmeter-7-在命令行中运行Jmeter.
jmeter -n -t D:\Jmeter_result\Script_baidu.jmx -l D:\Jmeter_result\Script_baidu.txt jmeter -n -t D:\ ...
- [Unity]用PropertyDrawer自定义struct/class的外观
一般来说,当我们要扩展编辑器时,我们会从Editor类继承,为自己的MonoBehaviour实现不同的外观. 但是如果有一个struct/class,在许多地方被使用,Unity默认的外观又不够好看 ...
- B. Complete the Word(Codeforces Round #372 (Div. 2)) 尺取大法
B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- POj 2104 K-th Number (分桶法+线段树)
题目链接 Description You are working for Macrohard company in data structures department. After failing ...
- 史诗级Java/JavaWeb学习资源免费分享
黑马内部视频+相关配套学习资料 Java Spring 技术栈构建前后台团购网站 Java SSM开发大众点评后端 欢迎关注微信公众号:Java面试通关手册 回复关键词: "资源分享第一波& ...