OT: need bash help

Pete Travis me at petetravis.com
Mon Oct 17 19:54:31 UTC 2011


Try wrapping your command to make a subshell:

LINES=$(ps x| grep mongod | wc -l)

HTH,

Pete
On Oct 17, 2011 1:39 PM, "Mike Wright" <mike.wright at mailinator.com> wrote:

> Hi all,
>
> I'm trying to write a bash script and having problems.
>
> If I execute this:
>
>   ps x | grep mongod | wc -l
>
> it returns a value.
>
> OTOH, if I execute this:
>
>   LINES = ps x | grep mongod | wc -l
>
> it returns "command not found".
>
> How does one assign the output of a command to an environment variable?
>
> TIA,
> Mike Wright
> --
> users mailing list
> users at lists.fedoraproject.org
> To unsubscribe or change subscription options:
> https://admin.fedoraproject.org/mailman/listinfo/users
> Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/users/attachments/20111017/93a29602/attachment.html 


More information about the users mailing list