fedora-users October 2011 archive
Main Archive Page > Month Archives  > fedora-users archives
fedora-users: Re: OT: need bash help

Re: OT: need bash help

From: Larry Brower <larry_at_nospam>
Date: Mon Oct 17 2011 - 19:43:22 GMT
To: users@lists.fedoraproject.org

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 10/17/2011 02:39 PM, Mike Wright 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

I think you are looking for:

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

-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJOnIVZAAoJEF1Xw4ZWTEoJHhoP/ArT7LZCFrjkhGS+ECi47rWK
xEelC7IC5oyZ/++LAp7dOimhLT3dV9B5UJxqffdXl4zxTbx+TrxulZhEjPG1vGz+
j1VfH9kPI3TawjQqO5soH0reWONfNDa0YIrl44CTnW+Drt9rqXl4c9tlNDfGilW2
zkj1zDCbegTdlVWlkiYvicWwFNfDx4qO0oh8hTKsCwqEhOMeL+swsnaKRhWn6Qke
tIV+zwUXiRTtBOaYvwd0KPJrZb6P8yfHSh2cDWkzpwHSH8t4pPvEgE8Z5rYTgy0M
AbSFOuMdotbgWyfHNMQHQNesHHAIipIr7OyYnVQ/rEM5pe4nKMtOknaSxonOkPcM
hNFwJNL2gOUL+xf77BO5jqu6YKw31+lkliuR6kiY/UYGOfN5vJFOxfz7R8x6Rde7
A5oo0Ta76BN75q0obNZiS+Rj+fn5cuIZyy657cDccLwK9VSF+vlAfhBZ1qb88nAr
ss9FvGwLhJeoxPw+nnFxlPAD0byl78TwbXEoQMDfLzwlPCHFAAqqVARlJcFtEmjG
yjEc4d5Jlps7MckD41FNBTkGQLXkyh78zpq82G7x0BRE/yluOAcZ9AZAjWTaToND
YD9kfT2kM86NxDzKvYHZPxqRpmzk8z+25j6oHNmwcjTY8Fe6kcWflriPXdSOvyxI
xdA/4NJzmb9wwP0OQzIz
=AcJ1
-----END PGP SIGNATURE-----
-- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines