#!/bin/sed -f s|||
Obviously, you would replace “yourcode” with whatever your analytics code happens to be. I used find to dig up all of the html pages and then ran this script via xargs, it would also be possible to use -exec:
find . -name "*.html" | xargs -n1 addanal.sh
The script itself contains just one “s” or substitute command. It uses the | or pipe symbol to delimit the arguments of the command. So, the script says that when sed encounters a body tag, replace it with the Google Analytics code and a new body tag. Simple.