mv,Directory not empty不能目录覆盖
一。mv /test1/* /test2/test1rm -rf /test1 二。 You can however usersyncwith the--remove-source-filesoption (and possibly others) to merge one directory into another.
rsync won't delete any directories, so you will have to do something like find -type d -empty -delete afterwards to get rid of the empty source directory tree.
rsync -av /source/ /destination/
(after checking)
rm -rf /source/
--remove-source-files has the advantage of only removing files that were transferred successfully, so you can use find to remove empty directories and will be left with everything that wasn't transferred without having to check rsyncs output
cd source; find -type f | xargs -n 1 -I {} mv {} dest/{}
三。
I'd recommend these four steps:
cd ${SOURCE};
find . -type d -exec mkdir -p ${DEST}/\{} \;
find . -type f -exec mv \{} ${DEST}/\{} \;
find . -type d -empty -delete
or better yet, here's a script that implements semantics similar to mv:
#!/bin/bash
DEST=${@:${#@}}; for SRC in ${@:1:$(({#@} -1))}; do (
cd $SRC;
find . -type d -exec mkdir -p ${DEST}/\{} \;
find . -type f -exec mv \{} ${DEST}/\{} \;
find . -type d -empty -delete
) done
|
Here is a script that worked for me. I prefer mv over rsync, so I use Jewel and Jonathan Mayer's solutions.
|
if you use use mv --backup=numbered
(or one of the other options for the --backup switch),
then mv will complete the merge and preserve the files intended to be overwritten
mv,Directory not empty不能目录覆盖的更多相关文章
- [linux] mv: cannot move $ to $: Directory not empty
最近测试某流程时,跑的过程报错了,于是检查脚本修改后重新测试.脚本是改过来了,但在shell中运行某步时碰到了如题报错! $ mv MP_genus_network_files/ tax_networ ...
- /Users/XX/Library/Developer/Xcode/DerivedData/XX.app/xxsdk.bundle Directory not empty
今天在升级xcode后真机调试偶然发现这个问题,查了一些资料发现还是不能完全解决 解决方法:参考的(http://blog.csdn.net/alincexiaohao/article/details ...
- 【Linux 命令】 rsync 目录覆盖软链接,保持软链接不变并同步目录内容
需求:有两个相同文件名的目录需要使用其中一个目录覆盖另外一个 问题: 被覆盖目录下存在软链接,但在源目录下软链接是一个目录 需要解决的方案: 要求将原目录里和被覆盖目录里冲突的目录文件复制到B的软链 ...
- OC报错,after command failed: Directory not empty
Directory not empty这个错误经常出现,出现的原因也很多,今天主要记录一下楼主自己碰到的这种情况. 全部错误提示: error: couldn't remove ‘路径/app-fzy ...
- Xcode 编译运行报错: CpResource /user/xxxx/ xxx Directory not empty
之前遇到过相同的问题,总是记吃不记打,踩过的坑后面还会踩进去... 仅以次标记加深一下印象 错误特征RT 确认该类型错误是library或frameWork的search路径问题 首先找到编译错误的路 ...
- 04_Linux目录文件操作命令1(mv ls cd...)_我的Linux之路
上一节已经给大家讲了Linux的目录结构,相信大家已经对Linux的整个目录结构有所了解 现实中,服务器(包含Linux,Unix,windows server)一般都摆放在机房里,因为一个机房摆放了 ...
- Linux文件与目录管理 - ls, cp, mv
[root@www ~]# ls [-aAdfFhilnrRSt] 目录名称 [root@www ~]# ls [--color={never,auto,always}] 目录名称 [root@www ...
- Shell命令-文件及目录操作之mkdir、mv
文件及目录操作 - mkdir.mv 1.mkdir:创建目录 mkdir命令的功能说明 mkdir命令用于创建目录,默认情况下,要创建的目录已存在,会提示文件存在,不会继续创建目录. mkdir命令 ...
- Linux 移动或重命名文件/目录-mv 的10个实用例子
本文导航 -初识 mv 命令03% -1.移动文件08% -2.移动多个文件15% -3.移动目录23% -4.重命名文件或目录27% -5. 重命名目录35% -6. 打印移动信息39% -7. 使 ...
随机推荐
- HDU_2032——杨辉三角
Problem Description 还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考以下的图形:11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1 ...
- HDU_2011——求多项式的前n项和
Problem Description 多项式的描述如下:1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + ...现在请你求出该多项式的前n项的和. Input 输入数据由2行组 ...
- 消除JavaScript闭包的一般方法
JavaScript 的闭包是一个其主动发展的特性, 也是一个被动发展的特性. 也就是说, 一方面, JS 有了闭包能更好解决一些问题. 另一方面, JS 为了解决某些问题, 而不得不使用闭包勉强来解 ...
- SVN权限修复
Description : Commit failed (details follow): Suggestion : The operation could not be completed. Tec ...
- [RxJS] Observables can complete
The Observer object has the functions next() and error(). In this lesson we will see the other (and ...
- IIS7 常用模块介绍说明
1.1.0 IIS常用的功能模块介绍: 1) 静态内容:可发布静态 Web 文件格式,比如 HTML 页面和图像文件. 2) 默认文档:允许您配置当用户未在 URL ...
- 关于Lambda表达式的理解
在.NET 1.0的时候,大家都知道我们经常用到的是委托.有了委托呢,我们就可以像传递变量一样的传递方法.在一定程序上来讲,委托是一种强类型的托管的方法指 针,曾经也一时被我们用的那叫一个广泛呀,但是 ...
- css中常用的标签
最常用的标签 left 左 top 上 right 右 bottom 下 font 字体 size 大小 width 宽度 height 高度 class 类 label 标签 form 表单 gro ...
- chkconfig(check config)命令
功能说明:chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. 语 法:chkconfig ...
- 关于sqfa
有的时候定义状态,下次来到这个状态的时候,不应该就否决掉下次,因为下次的权值可能比这次更优..