Re: [問題] 關於sed的問題
declare -a head=(`sed -rn 's/^(.{1}).*/\1/p' temp.prep |xargs`)
for ((i=1; i<=7; i++))
do
test "${head[$((i-1))]}" != "${head[$i]}" && sed -i "$i"G temp.prep
done
※ 引述《inmaze (拖鞋)》之銘言:
: 就是我有一筆資料叫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 `{'
: 請問板友能幫我解釋一下發生什麼事嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.200.52.15
※ 編輯: huo70 來自: 124.200.52.15 (08/23 05:29)
討論串 (同標題文章)