On 10/17/2011 07:39 PM, Mike Wright wrote:
> Hi all,
>
> I'm trying to write a bash script and having problems.
you seem to have several replies that can give you what you want.
here are a couple links that i have found helpful;
http://tldp.org/LDP/abs/html/
http://www.faqs.org/docs/abs/HTM
On 17 October 2011 20:45, Mike Wright wrote:
> On 10/17/2011 12: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 =
Backticks for a subshell are 'depricated' though the convention is still in
wide use. I use the $() method because `su - user 'command --opt="foo"'`
and such can get a bit confusing, and the alternative is much easier to
pick out of a mass of text.
On Oct 17, 2011 1:45 PM, "Mike Wright" wrote:
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" 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
On 10/17/2011 12: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 no
On 10/17/2011 12: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
-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 |
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 va