November 07, 2003

Multiple File Search and Replace

I found various ways to do search and replace across files, but the most concise way is to use Perl:

perl -pi -w -e 's/search/replace/g;' *.txt

Bear in mind what's between the single quotes after the -e option is a line of Perl code and the search argument is a regular expression, so some characters will have special meanings. You can escape special characters (like the forward-slash, dot, caret, dollar sign, and so on) by preceeding them with a back-slash.

Of course, if you know how to use Perl and regular expressions, this incantation becomes all the more powerful!

Posted by Rob at 11:53 PM | Comments (0)

May 06, 2003

List Files in an RPM

rpm -qpl <filename>
Posted by Rob at 11:39 AM | Comments (0)