關於sed的問題 - Linux

Table of Contents

就是我有一筆資料叫temp.prep

假設是這樣好了

0
0
0
0
1
1
1
1

我想要在0和1之間差一行空格
for ((i=1;i<=8;i++))
do
a=`head -n ${i} temp.prep | tail -n 1 | awk '{print $1}'`
j=$(($i+1))
b=`head -n ${j} temp.prep | tail -n 1 | awk '{print $1}'`


if [ "${b}" != "${a}" ] ; then
sed -i '${i}G' temp.prep
fi
done

但是出現了這個錯誤
sed: -e expression #1, char 0: unmatched `{'

請問板友能幫我解釋一下發生什麼事嗎?

--

All Comments

Daniel avatarDaniel2012-08-25
其他沒看,不過'${i}'不會展開變數