I'd like to insert
<?php include_once('google_analytics.php'); ?>
before the closing body tag of about 100 php files. Unfortunately the person who made the site didn't make a header or footer template.
What is the best way to do this? I've tried using grep/find for getting a list of files and piping the results through xargs to sed, but I've had no luck. I probably have the regex wrong. Can anyone help me out with this?
Also, are there any graphical tools for Apple OS X that you would recommend?
Thanks, Mike
edit
find . -print0 -name "*.php" | xargs -0 perl -i.bak -pe 's/<\/body>/<?php include_once("google_analytics.php"); ?>\n<\/body>/g'
works.