#!/bin/sh export LANG=zh_CN.GBK inputfile=$1 outputfile=$2 while true do HH=`date +%H` mv -f "$outputfile" "$outputfile.BAK" echo "generation $outputfile ${HH}" touch "$outputfile" while read LINE do datatime="" cymd=`date +%Y-%m-%d` chms=`date +%H:%M:%S` echo $LINE | awk -F ';' {'print $8'} | cut -c 12-19 | read datatime #echo "$chms --- $datatime" while [[ "$datatime" > "$chms" ]] do sleep 1 done mm1="" mm2="" #msg before datetime echo $LINE | cut -c -15 | read mm1 #msg after datetime echo $LINE | sed -e "s/2019-04-29/$cymd/g" | cut -c 16- | read mm2 if [[ "$3" == "1" ]]; then #return_before_line echo >> $outputfile fi printf "%s" "$mm1" >> $outputfile printf "%s" "$mm2" >> $outputfile if [[ "$3" == "" ]]; then #return_after_line echo >> $outputfile fi done < $inputfile CH=$HH while [[ "$CH" == "$HH" ]]; do sleep 1 HH=`date +%H` done done