 <p>To assign the output of a command to a variable, wrap the command in backticks or <code>$()</code>.</p> <pre><code>RESULT=$(cat $LOGFILE | tail -1) </code></pre> <p>Your command performed the environment variable assignment <code>RESULT=cat</code>, and then executed the command <code>$LOGFILE | tail -1</code> in that environment. Since <code>$LOGFILE</code> is not an executable file, you got an error.</p>