genlog_x.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. export LANG=zh_CN.GBK
  3. inputfile=$1
  4. outputfile=$2
  5. while true
  6. do
  7. HH=`date +%H`
  8. mv -f "$outputfile" "$outputfile.BAK"
  9. echo "generation $outputfile ${HH}"
  10. touch "$outputfile"
  11. while read LINE
  12. do
  13. datatime=""
  14. cymd=`date +%Y-%m-%d`
  15. chms=`date +%H:%M:%S`
  16. echo $LINE | awk -F ';' {'print $8'} | cut -c 12-19 | read datatime
  17. #echo "$chms --- $datatime"
  18. while [[ "$datatime" > "$chms" ]]
  19. do
  20. sleep 1
  21. done
  22. mm1=""
  23. mm2=""
  24. #msg before datetime
  25. echo $LINE | cut -c -15 | read mm1
  26. #msg after datetime
  27. echo $LINE | sed -e "s/2019-04-29/$cymd/g" | cut -c 16- | read mm2
  28. if [[ "$3" == "1" ]]; then
  29. #return_before_line
  30. echo >> $outputfile
  31. fi
  32. printf "%s" "$mm1" >> $outputfile
  33. printf "%s" "$mm2" >> $outputfile
  34. if [[ "$3" == "" ]]; then
  35. #return_after_line
  36. echo >> $outputfile
  37. fi
  38. done < $inputfile
  39. CH=$HH
  40. while [[ "$CH" == "$HH" ]];
  41. do
  42. sleep 1
  43. HH=`date +%H`
  44. done
  45. done