So testing a large change of adding a virtual include to all of the files in a website. Mainly for adding analytics tracking beneath the body tag for Google Tag Manager/Universal Analytics.
Making the change in all files with the .php extension
1 |
find ./ -type f -name "*.php" -exec sed -i.bak 's//\n<!-- #include virtual="includes/analytics-universal.php" -->/g' {} \; |
I’m not happy with what came about, so now I want to revert the change
1 |
find ./ -name "*.bak" -exec sh -c 'mv -f $0 ${0%.bak}' {} \; |
If you want to keep your changes, run this to get rid of the .bak files
1 |
find ./ -name "*.bak" -exec sh -c 'rm -f $0' {} \; |