I had an SVN Add crash on me and now the entire folder is locked such that any attempt to perform anything on that folder errors out. The Adds that did complete appear to be only locally and not pushed to the server, so I'm going to try to blow away all of the .svn folders locally and try adding again..... but that's a lot of manual deleting in Winblows, so here's some command-line-fu in Cygwin.
$ find . -iname *.svn | xargs -r -n 20 rm -rf
The 'find' stuff is obvious. The rest pipes the output from find into xargs which creates a list of 20 and executes 'rm -rf' on that list. The list size would obviously need to be adjusted to the expected number of hits. Sweet.
On another note, I recently had to resurrect an old project originally developed on Solaris. This particular project environment used several layers of Makefiles that called several different Perl scripts. The Perl scripts all pointed at the wrong path for the Perl executable in my Linux environment, so I had two options: 1) create a symbolic link in the directory the scripts pointed to (hack!) or 2) modify each of the scripts to point to the correct directory. The first is a hack, but the second takes quite a bit more time and when it comes to monotonous tasks like that, I'm fairly lazy and prefer an automated method. Hence the following:
$ grep –rl ‘/usr/local/bin/perl’ *.pl | xargs sed -i ‘s/\/usr\/local\/bin\/perl/\/usr\/bin\/perl/g’
The '-r' option tells grep to operate recursively through subdirectories and the '-l' option tells grep to return only the filename of the files containing matches. The output is piped to xargs and a simple sed switch is executed on each of the files. Brilliant!
No comments:
Post a Comment