※ 引述《s0805744 (Polatouche)》之銘言:
: 假設我有一個txt檔內容如下
: # name
: 1 2 3
: 4 5 6
: 我想要讀入這個檔案
: 然後對裡面的東西做運算該怎麼做
試試以下 script:
#!/bin/sh
sum=0
cat $1 | sed -e 's/ */ + /g' | while read line
do
if [ -n "$line" ]; then
sum=`expr $line + $sum`
echo $sum
fi
done
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.30.10.70