You have files under version control, which are updated through a different mechanism (software update, another VCS such as git, …) or are using svn to archive automatically generated files? Then you are likely to constantly manually determine the appropriate
svn add
and svn rm
commands. This can be automated…
The power of the Unix shell comes from the ability to daisy-chain simple commands, most of them reading from standard input and writing to standard output. The resulting pipeline can be very powerful. Here is an example. The output of svn status
(which files need to be added or removed) can be processed by the stream editor sed
to result in the right file names for the resulting svn add
and svn rm
commands with the help of xargs, which turns its standard input into command-line parameters for the given command.
So if you want to mark all newly-added files for addition to svn and all removed files for removal from the repository version, just issue the following two lines:
svn status | sed -n 's/^\?.......\(.*\)/\1@/p' | xargs -d '\n' svn add svn status | sed -n 's/^\!.......\(.*\)/\1@/p' | xargs -d '\n' svn rm
The difference between the two commands (! vs. ? and rm vs. add) are highlighted in red for educational purposes. Enjoy the power of the shell!
Leave a Reply
You must be logged in to post a comment.