我有一个带while循环的脚本:
DATA=$1
TMP_FILE=tmp_$RANDOM
cat $DATA.symbols | while read SYMBOL;
cat $DATA.symbols | while read SYMBOL;
do
grep $SYMBOL $DATA.tape > $TMP_FILE
TOTAL=`cat $TMP_FILE | wc -l`
FIRST=`awk '{print $3}' $TMP_FILE | head -1`
LAST=`awk '{print $3}' $TMP_FILE | tail -1`
SEC=`bc <<< "scale=3;$TOTAL/(24*60*60)"`
MIN=`bc <<< "scale=3;$TOTAL/(24*60)"`
HOUR=`bc <<< "scale=3;$TOTAL/24"`
echo "Total ticks for $SYMBOL: $TOTAL, first tick at: $FIRST, last tick at: $LAST, avarage 1 sec: $SEC, avarage 1 min: $MIN, avarage 1 hour: $HOUR" >> $DATA.stats
sed -i 's/\.[0-9][0-9][0-9]//' $DATA.stats
sed -i 's/\+0300//' $DATA.stats
done
但是当有2行时,循环在第一行停止。 如果我注释掉sed命令都可以。有没有办法在while循环中使用sed whith -i选项?