On Oct 22, 2008, at 23:01, Ruslan Sivak wrote:
> Ryan Schmidt wrote:
>
>> On Oct 22, 2008, at 03:19, Ruslan Sivak wrote:
>>
>>> Ryan Schmidt wrote:
>>>
>>>>> Looks like after I installed UnixUtils and changed the code
>>>>> slightly
>>>>>
>>>>> svn st --depth=infinity | sed -n "s/^\! //p" | xargs svn rm
>>>>>
>>>>> it seems to work. What if the file name has a spaces in it?
>>>>> Does anyone have a regex for that?
>>>>
>>>> The regular expression is accurate for any filename; the problem
>>>> is the xargs command which splits input on whitespace, whether
>>>> that be a newline or a space. Maybe there is an argument to
>>>> xargs to tell it to split only on newlines. Or you could replace
>>>> xargs with a short script written in perl or another language of
>>>> your choice. For example:
>>>>
>>>> svn st --depth=infinity \
>>>> | sed -n "s/^\! //p" \
>>>> | perl -e 'while (<>) {chomp;unlink;}'
[snip]
>>> There does seem to be a switch to xargs to tell it that you're
>>> separating filenames using the null character -0. Is there a way
>>> to do the regular expression to make it insert a null character
>>> there?
>>
>> I don't know a way to tell sed to use a null byte between output
>> lines instead of a newline.
>>
>> However, the tr utility can translate newlines to null bytes.
>>
>> svn st --depth=infinity \
>> | sed -n "s/^\! //p" \
>> | tr "\n" "\0" \
>> | xargs -0 -n 1 svn rm
>
> Thank you, that got me closer, but i'm still having issues. Here
> is a modified command line that has the nasty side effect of svn
> rming "." - the current directory.
>
> svn st --depth=infinity | sed -n "s/^\! //p" |tr "\n\r" "\0" |
> xargs -0 -n 1 --verbose
>
> >svn st --depth=infinity | sed -n "s/^\! //p" | tr "\n\r"
> "\0" | xargs -0 -n 1 --verbose -ixxx --no-run-if-empty svn rm
> \"xxx\"
> svn rm "New Text Document.txt"
> D New Text Document.txt
> svn rm ""
> D .
> svn: Unable to lock 'BE'
> svn rm "New Text Document (2).txt"
> D New Text Document (2).txt
> svn rm ""
> D .
> svn: Unable to lock 'BE'
>
>
> I'm not sure where the empty lines are coming from. Maybe some non-
> printable character? And svn just reinterprets it to mean "."?
> Russ
> P.S. BE is a folder under the images folder, which is under the
> current folder.
DOS/Windows line endings are \r\n, not \n\r. But you can't use tr
like that. It translates each character of the first argument to the
corresponding character in the second argument. If, as in your case,
there is only one character in the second argument, it replaces each
character from the first argument with the character from the second
argument. So all "\r" characters are being translated to null, and
all "\n" characters are being translated to null. Hence you have a
blank line between each line.
You may instead want to use tr twice, once to delete the "\r"
characters that come from being on Windows, and the second time to
translate the "\n" characters to nulls.
svn st --depth=infinity \
| sed -n "s/^\! //p" \
| tr -d "\r" \
| tr "\n" "\0" \
| xargs -0 -n 1 svn rm
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-10-23 06:11:58 CEST