[Solved] problem assigning value

Hi,

This is the script that am trying to execute.

a= sar 1 5 | grep ^A | awk '{print $5}'
echo $a

i am getting output.
99

i get a blank space for echo $a.
Why is the value not getting assigned to a??

Thanks in Advance.

Try:

a=$(sar 1 5 | awk '/^A/{print $5}')

maybe you're missing some quotes...

a="`sar 1 5 | grep ^A | awk '{print $5}'`"

note the difference between ` (backquote) and " (doublequote).

You did not say what shell you were using...
With ksh try:

a=$( sar 1 5 | grep ^A | awk '{print $5}')
echo $a

Franklin,

Now i get the output
98
11

"a" did not hold the value.

Aqualung,

The quotes did not help. It says it cannot find the directory.

Vbe,

I am using bash. And yes, I used $, but that did not help either.

n12:/home/vbe # echo $0
bash
n12:/home/vbe # sar 1 5 |grep ^A
AIX n12 1 6 00C8E5F24C00    11/10/11
Average       31      17       0      52    0.12    59.7
n12:/home/vbe # a=$( sar 1 5 | grep ^A | awk '{print $5}')
n12:/home/vbe # echo $a
00C8E5F24C00 77

AIX bash...

That worked..I guess there was some problem with the syntax :blush: