Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top