[BNE-PM] My 0 liner

Derek Thomson derek at wedgetail.com
Thu Sep 19 22:49:40 CDT 2002


Don.Simonetta at mincom.com wrote:
> 
> perl -p -i.bak -e '' <file list>
> 
> This will take a list of files and create copies of them with (in this
> case) a ".bak" extension. 
> 
> 

That's great! I use the "-i" option a lot to make global changes across 
lots of files in a source tree  (*), and I'd never thought of that. I 
think you clearly win the "shortest useful Perl program" award!

(*) As in something like:

$ find . -name '*.c' | xargs perl -p -i.bak -e 
's/old_func_name/new_func_name/g'

... and the old versions of all the files are safely backed up in the 
".bak" files.

--
D.




More information about the Brisbane-pm mailing list