I have the randomly generated password stored in
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $(cat /tmp/mysql_passwd.txt)"
This code is already correct as-written (though it's putting content on stdin rather than arguments, that's what
You can test this trivially:
echo "hello world" >file cat <<<"content follows: $(cat file)"
...the output of the above being:
content follows: hello world
Incidentally, when your shell is known to be bash you might consider
$(<file) as a more efficient replacement to