關於sed的問題 - Linux

By Mary
at 2012-08-21T12:53
at 2012-08-21T12:53
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 `{'
請問板友能幫我解釋一下發生什麼事嗎?
--
假設是這樣好了
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 `{'
請問板友能幫我解釋一下發生什麼事嗎?
--
Tags:
Linux
All Comments

By Daniel
at 2012-08-25T13:40
at 2012-08-25T13:40
Related Posts
有關顯卡驅動程式

By Susan
at 2012-08-21T09:59
at 2012-08-21T09:59
請問 VLAN (vconfig) + jumbo frames

By Aaliyah
at 2012-08-21T02:17
at 2012-08-21T02:17
KDE 也要有定期聚會了

By Xanthe
at 2012-08-20T17:00
at 2012-08-20T17:00
The Python GTK+ 3 Tutorial

By Daniel
at 2012-08-20T15:59
at 2012-08-20T15:59
協助 KDE 通知研究計畫

By Selena
at 2012-08-20T10:19
at 2012-08-20T10:19