Bri*_*acy 9 linux svn find recursive
我想从我的存储库中删除所有版本化文件,但保留版本化目录结构。显然我想保留所有 .svn 目录不变。
换句话说,我想在不损害目录结构本身的情况下完全清空工作副本的目录结构。
例如,从此结构中删除文件:
dir/
.svn/
[files]
svsubdir1/
file1
.svn/
[files]
subdir2/
file2
file3
file4
.svn/
[files]
subsubdir1/
file5
.svn/
[files]
Run Code Online (Sandbox Code Playgroud)
应该导致:
dir/
.svn/
[files]
svsubdir1/
.svn/
[files]
subdir2/
.svn/
[files]
subsubdir1/
.svn/
[files]
Run Code Online (Sandbox Code Playgroud)
我正在寻找某种find命令或其他东西来完成此任务,但在构建命令时遇到了麻烦。谢谢您的帮助!
Der*_*rfK 10
find dir/ -path '*/.svn' -prune -o -type f -print
Run Code Online (Sandbox Code Playgroud)
应该符合要求(主要来自 的查找联机帮助页-path)。用管道将其减少并检查一下。它首先查找(路径以 .svn 结尾并且不要递归到(修剪)这个目录)或(如果它是一个文件,打印它)。
如果看起来不错,请将其更改为
find dir/ -path '*/.svn' -prune -o -type f -exec rm {} +
Run Code Online (Sandbox Code Playgroud)
+ 版本将所有文件粘贴到一个 rm 命令中。如果您是偏执狂,请先备份树 ( cp -a dir/ otherdir/)。
| 归档时间: |
|
| 查看次数: |
3654 次 |
| 最近记录: |