Sending mail with subject as variable
<p>Here i want to send mail using unix shell scripting. </p>

<p>I use the following script for simple mailing:</p>

<pre><code>echo 'Message body goes here' | mail -s 'subject line goes here' email@provider.com
</code></pre>

<p><strong>Note</strong>: Now i want to send mail with the subject which comes from other file using the variable as shown below.</p>

<p><strong>File 1</strong>:</p>

<p>The file contains the following script:</p>

<pre><code>#!/bin/bash
subjectvariable="Subject is here" 
export $subjectvariable
</code></pre>

<p>I want to get this <code>$subjectvariable</code> should be used in the mail command as a variable. </p>

<p><strong>My try</strong>:</p>

<p><strong>File 2</strong>:</p>

<pre><code>#!/bin/bash
echo 'Message body goes here' | mail -s "$subjectvariable" email@provider.com
</code></pre>

<p>But in the output i am not getting the subject.</p>

<p>Variable works file for just echo command as shown below in the image:</p>

<p><a href="https://i.stack.imgur.com/PWJJi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PWJJi.png" alt="enter image description here"></a></p>