通过脚本删除物理文件已经不存在的文件

svn st | sed -n '/!/p' | awk '{print $2}' | xargs svn delete

或  
svn st | awk '{if ( $1 == "?") { print $2}}' | xargs svn delete

 

同理,可以添加未被svn纳管的文件,将delete 替换为 add

优化, 在 xargs中加入 -r 参数,如果输入参数为空时,不进行后面的操作

                                    -t 参数,先打印,在输出

svn st | awk '{if ( $1 == "!") {print $2}}' | xargs -t -r svn delete
svn st | awk '{if ( $1 == "?") {print $2}}' | xargs -t -r svn add

 

svn delete cnit/Packages/database-2.9.3-0033.x86_64.rpm cnit/Packages/logos-2.9.2-0024.x86_64.rpm cnit/Packages/vmd-2.9.3-7678.x86_64.rpm 
D         cnit/Packages/database-2.9.3-0033.x86_64.rpm
D         cnit/Packages/logos-2.9.2-0024.x86_64.rpm
D         cnit/Packages/vmd-2.9.3-7678.x86_64.rpm
svn add fronware/Packages/vmd-2.9.3-8860.x86_64.rpm fronware/Packages/fvi_version-2.9.6-0081.x86_64.rpm fronware/Packages/base-2.9.3-8864.x86_64.rpm fronware/Packages/web_evn-2.9.3-0033.x86_64.rpm fronware/Packages/logos-2.9.2-8632.x86_64.rpm fronware/Packages/system_update-2.9.3-8874.x86_64.rpm eclass/Packages/vmd-2.9.3-8860.x86_64.rpm eclass/Packages/fvi_version-2.9.6-0081.x86_64.rpm eclass/Packages/system_update-2.9.3-8873.x86_64.rpm eclass/Packages/base-2.9.3-8864.x86_64.rpm eclass/Packages/database-2.9.3-0035.x86_64.rpm eclass/Packages/web_evn-2.9.3-0033.x86_64.rpm eclass/Packages/logos-2.9.2-8632.x86_64.rpm qinghua/Packages/vmd-2.9.3-8860.x86_64.rpm qinghua/Packages/fvi_version-2.9.6-0081.x86_64.rpm qinghua/Packages/base-2.9.3-8864.x86_64.rpm qinghua/Packages/database-2.9.3-0035.x86_64.rpm qinghua/Packages/web_evn-2.9.3-0033.x86_64.rpm qinghua/Packages/logos-2.9.2-8632.x86_64.rpm qinghua/Packages/system_update-2.9.3-8874.x86_64.rpm cnit/Packages/vmd-2.9.3-8860.x86_64.rpm cnit/Packages/fvi_version-2.9.6-0081.x86_64.rpm cnit/Packages/base-2.9.3-8864.x86_64.rpm cnit/Packages/database-2.9.3-0035.x86_64.rpm cnit/Packages/web_evn-2.9.3-0033.x86_64.rpm cnit/Packages/logos-2.9.2-8632.x86_64.rpm cnit/Packages/system_update-2.9.3-8874.x86_64.rpm nologo/Packages/vmd-2.9.3-8860.x86_64.rpm nologo/Packages/fvi_version-2.9.6-0081.x86_64.rpm nologo/Packages/base-2.9.3-8864.x86_64.rpm nologo/Packages/database-2.9.3-0035.x86_64.rpm nologo/Packages/web_evn-2.9.3-0033.x86_64.rpm nologo/Packages/logos-2.9.2-8632.x86_64.rpm nologo/Packages/system_update-2.9.3-8874.x86_64.rpm 
A  (bin)  fronware/Packages/vmd-2.9.3-8860.x86_64.rpm
A  (bin)  fronware/Packages/fvi_version-2.9.6-0081.x86_64.rpm
A  (bin)  fronware/Packages/base-2.9.3-8864.x86_64.rpm
A  (bin)  fronware/Packages/web_evn-2.9.3-0033.x86_64.rpm
A  (bin)  fronware/Packages/logos-2.9.2-8632.x86_64.rpm
A  (bin)  fronware/Packages/system_update-2.9.3-8874.x86_64.rpm
A  (bin)  eclass/Packages/vmd-2.9.3-8860.x86_64.rpm
A  (bin)  eclass/Packages/fvi_version-2.9.6-0081.x86_64.rpm
A  (bin)  eclass/Packages/system_update-2.9.3-8873.x86_64.rpm
A  (bin)  eclass/Packages/base-2.9.3-8864.x86_64.rpm
A  (bin)  eclass/Packages/database-2.9.3-0035.x86_64.rpm
A  (bin)  eclass/Packages/web_evn-2.9.3-0033.x86_64.rpm
A  (bin)  eclass/Packages/logos-2.9.2-8632.x86_64.rpm
A  (bin)  qinghua/Packages/vmd-2.9.3-8860.x86_64.rpm
A  (bin)  qinghua/Packages/fvi_version-2.9.6-0081.x86_64.rpm
A  (bin)  qinghua/Packages/base-2.9.3-8864.x86_64.rpm
A  (bin)  qinghua/Packages/database-2.9.3-0035.x86_64.rpm
A  (bin)  qinghua/Packages/web_evn-2.9.3-0033.x86_64.rpm
A  (bin)  qinghua/Packages/logos-2.9.2-8632.x86_64.rpm
A  (bin)  qinghua/Packages/system_update-2.9.3-8874.x86_64.rpm
A  (bin)  cnit/Packages/vmd-2.9.3-8860.x86_64.rpm
A  (bin)  cnit/Packages/fvi_version-2.9.6-0081.x86_64.rpm
A  (bin)  cnit/Packages/base-2.9.3-8864.x86_64.rpm
A  (bin)  cnit/Packages/database-2.9.3-0035.x86_64.rpm
A  (bin)  cnit/Packages/web_evn-2.9.3-0033.x86_64.rpm
A  (bin)  cnit/Packages/logos-2.9.2-8632.x86_64.rpm
A  (bin)  cnit/Packages/system_update-2.9.3-8874.x86_64.rpm
A  (bin)  nologo/Packages/vmd-2.9.3-8860.x86_64.rpm
A  (bin)  nologo/Packages/fvi_version-2.9.6-0081.x86_64.rpm
A  (bin)  nologo/Packages/base-2.9.3-8864.x86_64.rpm
A  (bin)  nologo/Packages/database-2.9.3-0035.x86_64.rpm
A  (bin)  nologo/Packages/web_evn-2.9.3-0033.x86_64.rpm
A  (bin)  nologo/Packages/logos-2.9.2-8632.x86_64.rpm
A  (bin)  nologo/Packages/system_update-2.9.3-8874.x86_64.rpm

 

使用  --username   --password  参数设置 svn 使用的账户和密码

使用  --no-auth-cache 不保存密码 (没有此参数,会提示是否保存密码)

svn --username=zhangjichang --password=zhangjichang --no-auth-cache commit -m '构建版本: v2.9.6Build0081'

 

svn --username=zhangjichang --password=zhangjichang --no-auth-cache commit -m '构建版本: v2.9.6Build0081'

posted on 2017-06-30 14:58  doscho  阅读(223)  评论(0编辑  收藏  举报