Hi. I am having trouble trying to figure out why the following script does not work. It seems to be a variable scope issue but I don't know why the inner while loop can see the outer variable 'cpuinfo_output' but the rest of the script doesn't see the changes. I even exported the variable thinking that maybe the while loop was creating a sub shell. Please if anyone could help me, I would really appreciate it. Thanks.
cpuinfo=`grep -e processor -e "model name" -e "cache size" /proc/cpuinfo -h | sed 's/^.*: //'`
echo "parent pid = $$"
echo "$cpuinfo" > /tmp/.heartbeat.tmp
cat /tmp/.heartbeat.tmp | (
while read i
echo "pid = $$"
echo "--> '$cpuinfo_output'"