Replace pipe character "|" with escaped pip character "\|" in string in bash script
<p>I am trying to replace a pipe character in an String with the escaped character in it:</p>

<p>Input: <strong>"text|jdbc"</strong>
Output: <strong>"text\|jdbc"</strong></p>

<p>I tried different things with tr:</p>

<pre><code>echo "text|jdbc" | tr "|" "\\|"
...
</code></pre>

<p>But none of them worked.
Any help would be appreciated.
Thank you,</p>