我有一个代码:
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?