Created
April 16, 2025 14:05
-
-
Save netologist/9f68a2d29a2ec51f07bb05df3c712d4d to your computer and use it in GitHub Desktop.
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 characters
#!/bin/bash | |
# Check arguments | |
if [ $# -lt 1 ]; then | |
echo "Usage: $0 <filename>" | |
exit 1 | |
fi | |
FILE="$1" | |
# Make a backup first | |
cp "$FILE" "$FILE.bak" | |
# Replace {{{VAR}}} and {{VAR}} with $VAR (any variable name) | |
perl -pe 's/\{\{\{\s*(\w+)\s*\}\}\}/\$$1/g; s/\{\{\s*(\w+)\s*\}\}/\$$1/g' "$FILE.bak" > "$FILE" | |
echo "Replacements complete. Backup saved as $FILE.bak" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment