Poster of Linux kernelThe best gift for a Linux geek
msrp

msrp

Section: User Manuals (1) Updated: DEC 2007
Local index Up
 

NAME

msrp - search and replace file contents and metadata recursively.  

SYNOPSIS

msrp searchpat repstr [-cdfipqsw] [--svn | --hg] [file1 | dir1/] [file2 | dir2/]...  

DESCRIPTION

msrp reads in one or more file or directory arguments and applies a regular-expression based global transformation. It searches for searchpat as a Perl 5 compatible regular expression and substitutes repstr for it for all listed arguments that follow. msrp applies the substitution to both the contents of files as well as the filenames themselves. If a filename is changed by a substitution, then the file is renamed to reflect the new value. This type of renaming is useful when using filenames that are also used in program source code text and both must be kept consistent together. If a directory argument is given, that directory is recursively traversed unless the -s option is given. Directories can also be renamed and all three modes of operation are enabled by default. File contents, file names, and directory names are all transformed by the given regular expression substitution. Note that subdirectories starting with . are not entered recursively unless the --dot-paths option is specified.

If a numbered back-substitution group is wanted, simply use a backslash followed by a decimal digit to refer to a captured group in the replacement string. Capture group 0 represents the entire match string.

If a file is unchanged by a given regular expression then it will not have its modification time updated by msrp. Only files that are actually changed are touched. If a file would be changed or a file modification would overwrite a preexisting file, then an .orig.1 file will be created. The following options can customize behavior:

-c
disable file contents transformation
-d
disable directory renaming transformation
-f
disable filename renaming transformation
-i
perform case-insensitive matching
-p
preserve mode, so that .orig files are created (default is overwrite mode)
-q
quiet mode, with no extra status messages
-s
do not recursively enter subdirectories
-w
enable word-boundary constraint. This means the matched expression must begin and end with a word boundary, as in perl \b regexp notation.
--hg or --mercurial
enable Mercurial renaming.
--svn or --subversion
enable Subversion renaming.
 

EXAMPLES

Rename all files in the current directory recursively searched that end with the extension .html and rename them to .htm without touching file contents or directories:
msrp -c -d '(.*)html$' '\1htm' .
Copy olddebian/ dir to debian/ while changing oldpkgname to newname in
files, directories, and filenames:
cp -rv olddebian/ debian && msrp oldpkgname newname debian
Normalize extension case of .c files so .C becomes .c:
msrp -c -d -i '(.*)\.c$' '\1.c' .
Rename vector to zector in Subversion:
msrp --svn vector zector .
 

ENVIRONMENT

No environment variables.  

BUGS

Please report bugs to the Debian BTS.  

AUTHOR

Rudi Cilibrasi <cilibrar@cilibrar.com>


 

Index

NAME
SYNOPSIS
DESCRIPTION
EXAMPLES
ENVIRONMENT
BUGS
AUTHOR

This document was created by man2html, using the manual pages.
Time: 21:24:06 GMT, April 16, 2011