当前位置:网站首页>SVN如何删除文件名包含空格的文件
SVN如何删除文件名包含空格的文件
2022-08-02 10:09:00 【AlbertS】
前言
SVN 和 Git 两个常用的版本管理工具都有 add 和 commit 命令,但是这两个命令的含义是不同的,git add 命令添加的是变化的文件,不管是增加的文件、删除的文件还是更新的文件,使用 git add 命令之后都可以放到暂存区,而 svn add 命令只能影响新增和变化的文件,对原在库中现已删除的文件没有影响,想要真正删除文件需要在执行 svn commit 命令之前先执行 svn delete 命令。
SVN删除文件
SVN 删除文件需要指定文件名字,而使用在一些自动化脚本中时,被删除的文件都是其他脚本自动删除的,要想获得这些文件的名字,可以利用 svn st 命令来查询,然后搭配管道再使用 svn del 命令来删除这些文件。
$ svn st
! test/A.txt
! test/B.txt
! test/C Blank.txt
! test/DD.txt
M test/E.txt
? test/F.txt
A test/G.txt
svn st 命令的结果对每个变化文件显示一行,第一列是文件状态,第二列及后面的部分是文件名
!:表示已经删除的文件M:表示文件内容发生变化的文件?:表示一个新文件,不在原版本库中A:表示本次新增的文件
要想删除文件只需要把 ! 开头的文件删除就可以了,常规命令如下:
svn st | grep ^! | awk '{print " --force "$2}' | xargs -r svn del
这个命令就是要生成 svn del --force test/A.txt 命令然后执行,这样就能达到删除文件的目的了
基于这个目的,一般自动化部署的机器上的svn提交命令如下:
svn st | grep ^! | awk '{print " --force "$2}' | xargs -r svn del
svn add . --no-ignore --force
svn commit -m "build message"
被删除的文件名带空格
上述命令能处理绝大部分的情况,但是如果被删除的文件中包含空格,那么执行命令时就会报错:
$ svn st | grep ^! | awk '{print " --force "$2}' | xargs -r svn del
svn: E125001: 'test/C' does not exist
为什么会报错的呢?就是说因为文件 test/C Blank.txt 的名字中包含了空格,使用 awk '{print " --force "$2}' 把空格后半部分的文件名丢掉了,所以只要处理一下这种情况就可以了,处理命令如下:
svn st | grep ^! | awk '{$1="";print $0 }' | awk '$1=$1' | awk '{print " --force ""\""$0"\""}' | xargs -r svn del
svn st显示个文件状态grep ^!过滤出原在版本库中但现已删除的文件awk '{$1="";print $0 }'去掉每行信息中第一列的状态值awk '$1=$1'去掉数据开头和结尾的空格awk '{print " --force ""\""$0"\""}'拼接文件名,并在前后添加引号,--force "test/C Blank.txt"xargs -r svn del利用管道传递文件名将文件删除
总结
svn st命令可以查询SVN当前目录下各个文件的状态svn del命令用于删除原版本库中的文件- 如果待删除的文件名包含空格可使用
svn st | grep ^! | awk '{$1="";print $0}' | awk '$1=$1' | awk '{print " --force ""\""$0"\""}' | xargs -r svn del
互发声明并非只是打打嘴架,应该是在相互试探着对方的底线,各自盘算着多方的利益,双方也都是极其聪明的人,背后都有强大的团队提供支持,博弈啊博弈,每一方都会选择对自己最有利的行动~
边栏推荐
- Facebook自动化数据分析方案,广告投放省心省力
- HikariCP database connection pool, too fast!
- DVWA Clearance Log 2 - Command Injection
- 一款优秀的中文识别库——ocr
- 8月份的.NET Conf 活动 专注于 .NET MAUI
- R语言时间序列数据算术运算:使用log函数将时间序列数据的数值对数化、使用diff函数计算对数化后的时间序列数据的逐次差分(计算价格的对数差分)
- Verilog's random number system task----$random
- R语言ggplot2可视化:使用ggpubr包的ggbarplot函数可视化水平柱状图(条形图)、使用orientation参数设置柱状图转置为条形图
- 日元疲软令游戏机在日本变身“理财产品”:黄牛大赚
- Smoothing of time series data in R language: smoothing time series data to remove noise using the dpill function and locpoly function of the KernSmooth package
猜你喜欢

iNFTnews | Seeing the two sides of the metaverse, what is the true Internet and the Internet of value?

日元疲软令游戏机在日本变身“理财产品”:黄牛大赚

HikariCP database connection pool, too fast!

Getting Started with SCM from Scratch (1): Summary of Background Knowledge

李航《统计学习方法》笔记之感知机perceptron

Use the scrapy to climb to save data to mysql to prevent repetition

Using the TCP protocol, will there be no packet loss?

npm ERR! 400 Bad Request - PUT xxx - Cannot publish over previously published version “1.0.0“.

DVWA 通关记录 2 - 命令注入 Command Injection

Linux系统卸载,安装,升级,迁移clickHouse数据库
随机推荐
读博一年后对机器学习工程的思考
DVWA 通关记录 2 - 命令注入 Command Injection
matlab-day02
js防抖函数和函数节流的应用场景
function call to print lua internal structure
适配器模式适配出栈和队列及优先级队列
DVWA Clearance Log 2 - Command Injection
Spearman's correlation coefficient
2022.7.25-7.31 AI行业周刊(第108期):值钱比赚钱更重要
iNFTnews | Seeing the two sides of the metaverse, what is the true Internet and the Internet of value?
R language time series data arithmetic operation: use the log function to log the time series data, and use the diff function to calculate the successive difference of the logarithmic time series data
R语言ggpubr包的ggline函数可视化分组折线图、add参数为mean_se和dotplot可视化不同水平均值的折线图并为折线图添加误差线(se标准误差)和点阵图、自定义palette设置颜色
【术语科普】关于集成工作台那些难懂的词儿,看这篇秒懂!
Facebook's automated data analysis solution saves worry and effort in advertising
用了TCP协议,就一定不会丢包嘛?
练习-17
后管实现面包屑功能
DirectX修复工具增强版「建议收藏」
如何安装dosbox(pycharm详细安装教程)
The ggbarplot function of the R language ggpubr package visualizes the grouped histogram, sets the add parameter to mean_se to visualize the histogram of the mean values of different levels and adds