troubleshooting Question

Variable not found ksh script error

Avatar of YZlat
YZlatFlag for United States of America asked on
Shell Scripting
6 Comments1 Solution980 ViewsLast Modified:
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros