mv,Directory not empty不能目录覆盖
2015-06-14 23:36
447 查看
一。 mv /test1/* /test2/test1 rm -rf /test1 二。 You can however use [code]rsyncwith the
--remove-source-filesoption (and possibly others) to merge one directory into another.
[/code]
rsyncwon't delete any directories, so you will have to do something like
find -type d -empty -deleteafterwards to get rid of the empty source directory tree.
rsync -av /source/ /destination/ (after checking) rm -rf /source/to remove empty directories and will be left with everything that wasn't transferred without having to check--remove-source-fileshas the advantage of only removing files that were transferred successfully,
so you can use [code]find
rsyncs output[/code]
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
0 down vote | Here is a script that worked for me. I prefer mv over rsync, so I use Jewel and Jonathan Mayer's solutions.#!/bin/bash# usage source1 .. sourceN destlength=$(($#-1)) |
if you use usewill complete the merge and preserve the files intended to be overwrittenmv --backup=numbered(or one of the other options for the --backup switch),then [code]mv
[/code]
相关文章推荐
- Sidekiq错误处理
- mv,Directory not empty不能目录覆盖
- POJ 3281 Dining 最大流 Dinic算法
- 团队作业-第四周-面向对象程序设计
- 关于“接口”的理解
- xxx cannot be resolved to a type 错误解决方法
- 第五节:使用反射发现类型成员
- spark入门讲座
- php换行符
- Java中的对象和对象引用
- 第一阶段冲刺总结
- matlab pca 函数 输入输出数据的意义
- 2015061409 - 怎么看公司给新员工的薪水高于老员工的薪水?
- 正则表达式
- DELET语句与REFERENCE约束“FK_news_category”冲突,该冲突发生于数据库“newssystem”,表dbo.news,column 'caId'语句终止
- <一> Linux是什么
- Linux添加 用户
- Functional MRI (second edition) -- 1. An introduction to fMRI
- NSArray中地内存管理 理解
- 、为什么要使用委托?