 <p>It should work.</p> <p>Here's how</p> <pre><code>$ echo Helloabtb | perl -0777pe 's/a/x/g' Helloxbtb $ myvar=`echo Helloabtb | perl -0777pe 's/a/x/g'` $ echo $myvar Helloxbtb </code></pre> <p>So if it works with <code>echo</code> it should work with <code>cat</code>. I suggest using backticks as shown above in my example, and try. Something like</p> <pre><code> findString=`cat $findString | perl -0777pe 's/\t/\\t/g'` </code></pre> <p>also in most probability, <code>cat</code> expects a file. So in your case <code>echo</code> might be suited as</p> <pre><code>findString=`echo $findString | perl -0777pe 's/\t/\\t/g'` </code></pre> <p>OR</p> <pre><code>findString=$(echo "$findString" | perl -0777pe 's/\t/\\t/g') </code></pre> <p>OR</p> <pre><code>command="echo $findString | perl -0777pe 's/\t/\\t/g'" findString=eval($command) </code></pre>