我有一个代码:
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
问题是:首先echo $sup
写1
但第二个echo $sup
没有写任何内容。为什么我不能从“while”中获得$ sup?