I've tried this:
echo $RANDOM | md5sum | head -c 20 | { read val; sed -i 's/__SALT__/$val/g' app.txt; }
But this replaces __SALT__ with the string $val instead of the value in the variable.
I've tried this:
echo $RANDOM | md5sum | head -c 20 | { read val; sed -i 's/__SALT__/$val/g' app.txt; }
But this replaces __SALT__ with the string $val instead of the value in the variable.
Found the solution here: Passing a variable to sed
Just needs double quotes:
echo $RANDOM | md5sum | head -c 20 | { read val; sed -i "s/__SALT__/$val/g" app.txt; }