あみだくじ
Posted feedbacks - Other
おなじ方法のものを, bourne shell + sed で
1 2 3 4 5 6 7 | #! /bin/sh
cat $1;t="mktemp tmp.XXXXXX";F=`$t`;R=`$t`;t=`$t`;head -n1 $1>$F;cat $1|sed \
-e1d >$R;while ! test 0 = `cat $R | wc -l`;do X=;r=;i=1;p=0;L=`head -n1 $R|sed\
-e 's/|-|/-/g'|sed -e 's/|/+/g'`\ `head -n1 $R |sed -e 's/-/ /g'`;for c in $L
do case $c in -)r=$r" \\"`expr 1 + $i`" \\$i";p=2;;+)r=$r" \\"$i;p=1;;\|)
X=$X'\(.\) ';;esac;i=`expr $i + $p`;done;s=s/`echo $X`/`echo $r`/;cat $F|sed \
-e "$s">$t; cp $t $F;cat $R|sed -e '1d' > $t;cp $t $R;done; cat $F;rm $R $F $t;
|




greentea #4476() Rating4/6=0.67
[ reply ]