2006
08.24

neat little perl trick

you ever have a shitload of files in a directory that needed one thing (the same in all) changed ??

here is this cool little perl trick to change that one object in all the files without having to edit them all by hand

perl -pi.bak -e 's/foo/bar/i' *.extention

by running this with the -p it runs it from the command line as a script

the i creates the backups of the files (henceforth the .bak)

try it – just replace “foo” with the text that has to be replaced and “bar” with the new text.

*.extention is the file name(s) as to replace

No Comment.

Add Your Comment
  1. If you have any interest in Perl AI (artificial intelligence)
    http://ai.neocities.org/P6AI_man.html is the User Manual for the AI I am working on in Perl for thinking in English, German and Russian.