<p>Try wrapping your command to make a subshell:</p>
<p> LINES=$(ps x| grep mongod | wc -l)</p>
<p>HTH,</p>
<p>Pete</p>
<div class="gmail_quote">On Oct 17, 2011 1:39 PM, &quot;Mike Wright&quot; &lt;<a href="mailto:mike.wright@mailinator.com">mike.wright@mailinator.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I&#39;m trying to write a bash script and having problems.<br>
<br>
If I execute this:<br>
<br>
   ps x | grep mongod | wc -l<br>
<br>
it returns a value.<br>
<br>
OTOH, if I execute this:<br>
<br>
   LINES = ps x | grep mongod | wc -l<br>
<br>
it returns &quot;command not found&quot;.<br>
<br>
How does one assign the output of a command to an environment variable?<br>
<br>
TIA,<br>
Mike Wright<br>
--<br>
users mailing list<br>
<a href="mailto:users@lists.fedoraproject.org">users@lists.fedoraproject.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="https://admin.fedoraproject.org/mailman/listinfo/users" target="_blank">https://admin.fedoraproject.org/mailman/listinfo/users</a><br>
Guidelines: <a href="http://fedoraproject.org/wiki/Mailing_list_guidelines" target="_blank">http://fedoraproject.org/wiki/Mailing_list_guidelines</a><br>
</blockquote></div>