Link to home
Start Free TrialLog in
Avatar of YZlat
YZlatFlag for United States of America

asked on

Variable not found ksh script error

here is my code:

total_size=0
du -g $dir | temp_size=$( awk '{c+=$1};END { print c }')
echo $temp_size
$total_size += $temp_size

I get an error:

./myscript.ksh[7]: 0:  not found.

I also tried

total_size=0
du -g $dir | temp_size=$( awk '{c+=$1};END { print c }')
echo $temp_size
total_size += $temp_size

but that gave me almost the same error:

./myscript.ksh[7]: total_size:  not found.
ASKER CERTIFIED SOLUTION
Avatar of radynski
radynski

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat

ASKER

Now I get

 +=: 0403-058 Assignment requires an lvalue.

even thoug I did assign it the value of 0 initially
Avatar of YZlat

ASKER

I also tried

let total_size = $(total_size  + $temp_size)

but that gives me 2 errors;

 0:  not found.
 =: 0403-058 Assignment requires an lvalue.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did you mean
total_size+=$temp_size
Avatar of YZlat

ASKER

part of the solution found myself