views:

119

answers:

1

I am trying to change certain lines in multiple files (scattered in subfolders) without having to edit each file one by one. I was given by Chas. the following

perl -pi.bak -e 's{[^/]Css/Template.css}{/Css/Template.css}' *

and it worked like a charm but was wondering if this command or similar can be done recursively in one shot

+3  A: 
find . -type f -exec perl -pi.bak -e 's{[^/]Css/Template.css}{/Css/Template.css}' '{}' '+'

This will apply it to all files in the current directory and all subdirectories. It will not follow symlinks. You might want to narrow the scope of the find with a -name directive as well.

bdonlan
Thanks, it works! I thought adding -r would do it recursively, heh. Now time to remove those bak files ...
damx
You can use find again to easily get rid of those .bak files too :)
bdonlan
*slap in the head* how embarrassing ... look away
damx