Related Entries

Bash infinite loop script
Unix's revenge
Corn on unix
*Nixing linkfest 2002.10.04
Unixifying Windows

« Contracting God
» War on common sense

Find and replace locks

Search for file content and replace.

I don’t get much time to fix things in Unix at work these days. Today, I found out that lot of files that were converted from RCS to CVS had strict locks, by an ex-employee.

Easiest thing was to convert the locks from ex-employee to a new employee. So, go the repository root and here is the simple shell script to change the files that are locked.

for f in `egrep -lr -E "exemployee:[0-9]+\.[0-9]+; strict;" *`
        perl -i -p -e "s|exemployee:(.*?); strict;|newemployee:\1; strict;|gi" $f

Why blogging this silly thing? Till 2000, I used to work extensively on Unix and have written lots of shell scripts. I simply wonder if I had these snippets saved somewhere. May be I should make a cookbook or wiki.