Created
May 30, 2023 01:12
-
-
Save mkamrani/a159516f73db0e8adf10e5d88ec2a370 to your computer and use it in GitHub Desktop.
Revisions
-
mkamrani created this gist
May 30, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/bin/bash # From: dotenx.com # description: # Add Google Analytics to all HTML files in a directory. Google Analytics code should be in a file called google-analytics in the same directory as this script. # usage: # ./add-gtag.sh directory # Tested on Mac-zsh directory="$1" if [ -d "$directory" ]; then for file in "$directory"/*.html; do if [[ -f "$file" ]]; then sed -i.bak '/<head>/r google-analytics' $file fi done else echo "Directory not found." fi rm $directory/*.bak