What can I do to fix this?
Refactor your idea to write it in a single performant programming language. Bash is a shell - it executes other programs. Each program takes time to start.
You could generate sed script in one go and then execute it. Note that this will not handle ^hello
or any other .
*
[
?
\
characters correctly, as sed works with regex. ^
matches beginning of a line.
sed "$(sed 's/\([^=]*\)=\(.*\)/s`\1\\b`\2`g/g' "$PROPERTIES_FILE")" "$INPUT_FILE"
echo "$INPUT"
You could escape the special characters with something along like this. See also https://stackoverflow.com/a/2705678/9072753 .
sed "$(sed 's/[]\/$*.^&[]/\\&/g; s/\([^=]*\)=\(.*\)/s`\1\\b`\2`g/g; ' "$PROPERTIES_FILE")" "$INPUT_FILE"
Notes: use shellcheck. Use $(...) instead of backticks. Do not abuse cats - just use <file
instead of <<<$(cat "$PROPERTIES_FILE")
. Don't SCREAM - consider lowercase variables.