I find the best solution for my problem here: Howto fix subversion «!» status
But now, I just wish to write a small script to do that.
Like this:
svn status | grep '\!' | awk '{print $2}' | xargs svn revert
svn status | grep '\!' | awk '{print $2}' | xargs svn delete
But in one line.
Because, after the svn revert, “svn status | grep ‘!'” return no results. Rational.
I think that I found a solution: Putting the data passed to xargs twice in one line but I’m little rusty in English and command line isn’t my strong skills.
The
teecommand is like a T pipe fitting; one copy of the output goes to each named file and another to standard output. Here, I’ve named just one file. This forces all the reverts to happen before any of the deletes.The namelist.$$is a simple way of protecting the script from trampling on the files of other processes; there are programs likemktempthat can be used to create more secure, less predictable names. OTOH, if you aren’t running in hostile environments, it is unlikely to matter. If you’re being really careful, you’ll create atrapto ensure the file is cleaned up:There are other tricks that could be tried, but at least some of them don’t guarantee the sequential operation. For example, process substitution in
bash:Each file will be both reverted and deleted, but the sequencing is not predictable.