diff options
author | Grail Finder <wohilas@gmail.com> | 2023-03-09 22:53:04 +0600 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2023-03-09 22:53:04 +0600 |
commit | 481955c6ba61bb6d415f9a3a963a04931af95696 (patch) | |
tree | bcc01f67b5ef1037d830ab0ae173cd8cdcd1f91b /replace_phrase.sh | |
parent | 5146dc3cef9aac7ab37d767ebea559ad10d46139 (diff) |
Feat: add scripts to generate dynamic data
Diffstat (limited to 'replace_phrase.sh')
-rwxr-xr-x | replace_phrase.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/replace_phrase.sh b/replace_phrase.sh new file mode 100755 index 0000000..1b61476 --- /dev/null +++ b/replace_phrase.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +# phrase=$(cat phrase) +phrase=${1:-"test phrase"} + +echo "$phrase" + +# if multiline +# https://stackoverflow.com/questions/10107459/replace-a-word-with-multiple-lines-using-sed/#22901380 +# escapedPhrase="$(echo "${phrase}" | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/\$/\\$/g')" + +# just do oneline +phrase=$(echo $phrase | tr "\n" " ") + +sed -i -e "s|\(<p id=phrase>\)\(.*\)\(</p>\)|\1${phrase}\3|" index.html |