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 ;)