Skip to content

Instantly share code, notes, and snippets.

@daskol
Created January 19, 2018 22:40
Show Gist options
  • Save daskol/382ed5cef98cc1236b34e3d520b74353 to your computer and use it in GitHub Desktop.
Save daskol/382ed5cef98cc1236b34e3d520b74353 to your computer and use it in GitHub Desktop.
Inject Yandex Metrica counter into all HTML files after <body> tag.
#!/bin/bash
# inject-metrica.sh
# Inject Yandex Metrica counter into all HTML files after <body> tag.
COUNTER='<put Yandex Metrica one-line counter here>'
COUNTER=$(sed 's/\//\\\//g' <<< $COUNTER)
for file in $(ls *.html); do
echo "processing $file"
sed -i "s/<body>/<body>\n$COUNTER/g" $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment