Reputation: 1828
I've got a code:
od -An -t x1 <"$file" |
while read line;do
for char in $line;do
if [ $needspace -eq 0 ]
then
export hexs=$hexs`printf "%.2s" "$char"`
needspace=1
else
export hexs=$hexs`printf "%.2s " "$char"`
needspace=0
fi
if [ `printf "%d" "0x$char" ` -lt 32 ] || [ `printf "%d" "0x$char"` -gt 126 ]
then
text=$text.
else
text=$text`echo -e "\x$char"`
fi
charsnow=$(($charsnow+1))
done
sup=1
echo $sup
done
echo $sup
The problem is: first echo $sup
writes 1
But second echo $sup
writes nothing. Why can't I get $sup out of "while"?
Upvotes: 1
Views: 153
Reputation: 6577
You have a subshell, so side-effects can't occur. http://mywiki.wooledge.org/BashFAQ/024
Upvotes: 3