首列相同内容合并内容通行脚本
#!/bin/sh
FILE=/home/xxx/peizhi
FILE2=/home/xxx/result.txt
NUM=0
NUM2=0
while read line
do
let NUM++
if [ $NUM -gt 2 ]
then
echo "$line"
SN=`echo $line|awk '{print$1}'`
BOM=`echo $line|awk '{print$2}'`
ZLINE=`tail -n 1 $FILE2`
SN2=`echo $ZLINE|awk '{print$1}'`
if [ $SN == $SN2 ]
then
echo $BOM
sed -i "${NUM2}s/$/&\t$BOM/" $FILE2
else
echo $line >> $FILE2
let NUM2++
fi
else
echo $line >> $FILE2
let NUM2++
fi
done < $FILE
链接: link.