How to clean version control $Id$ comment
This might be a common question, but search engines are horrible at searching for non-alphanumeric characters.
I have a bunch of code which contains the standard version control $Id$ tag/comment. I need an easy way to remove (clean, strip), all of these tags from every file in a directory structure.
Specifically this is a PHP script (phpBB to be specific), and so looks like this:
<?php
/**
*
* @package acp
* @version $Id: acp_attachments.php 8479 2008-03-29 00:22:48Z naderman $
*
*/
?开发者_Go百科>
The line I want to change is this:
* @version $Id: acp_attachments.php 8479 2008-03-29 00:22:48Z naderman $
So the line becomes:
* @version $Id$
Keep in mind, I'm on Windows, so I can't use a Linux command for find/replace. But I do have the ability to run PHP to act on all my files.On windows you can use grepWin
using this regex:
Search for: \$Id\: .+ \$$
Replace with: \$Id\$
NOTE: first make a backup of all files before doing this
Can you use Perl? Here's my cvs-clean
script that I use for this:
#!/usr/bin/perl
use strict;
use warnings;
while (<>) {
s/\$([A-Z][a-z]+):[^\$]*\$/\$$1:\$/g;
print;
}
It filters stdin to stdout. It's not exactly what you asked for; it changes $Id: blah $
to $Id:$
. Delete the last :
in the s///
command to change that.
If you can't use Perl, translating this to PHP is left as an exercise.
精彩评论