Svn practice notes ---- script: SVN batch addition and deletion

Source: Internet
Author: User
Hello everyone, this article involves a practical problem I encountered when using svn: how to complete commands involving multiple files at a time. Hello everyone, this article involves a practical problem I encountered when using svn: how to complete commands involving multiple files at a time.

Generally, svn add and svn rm are used to perform file operations under svn version control, such as adding and deleting files, so that svn can know these changes, however, in actual use, the version folder is usually the Eclipse project folder. if you want to delete the added file and directly operate in Eclipse, why should you jump to the command line? [It seems that there are related functions in eclipse, but I haven't carefully looked at them for the moment ...]

The consequence of performing operations directly in Eclipse is that during svn submission, the svn st command list contains '? ', And there will be '1' before the deleted file, we need to put '? ', Right? The row uses svn rm. how does one perform this batch operation?

Through "svn st | grep ?" Command to get the list of files to be added, but each line uses '? ', So xargs cannot be directly passed to svn add. So how can we convert those questions? Filter out?
Example:
The file list is as follows:
D: \ PROJET \ repo \ trunk> svn st | grep?
? Main. xml
? Logo.png
? Bin
? Gen
? Add.png
Command: svn add main. xml logo.png bin gen add.png

Note that using svn add-A is not A good method. for my new user, the solution is not too obvious, but after research and posting for help, I still found the answer;

Svn st | grep? | Sed "s /? // "| Xargs svn add

Svn st | awk '{if ($1 = "? ") {Print $2} '| xargs svn add

The first solution uses sed? Replace it with null and pass it over. The second method uses the awk command. These two commands are very commonly used for string replacement and other processing, with their ideas, they will be complete. we recommend that new users like me study sed and regular expressions and combine them into powerful scripts ;)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.