Advertisement
TonyAR

Untitled

Dec 8th, 2022 (edited)
722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.86 KB | Source Code | 0 0
  1. #!/bin/bash
  2. # this file: go.sh (calls conv_log.sh)
  3. #
  4. outfile="./usage_log"
  5. rm -f $outfile
  6. #
  7. while read fname
  8. do
  9. logdate=$(echo $fname |awk -F "/" '{print $6}' |awk -F "." '{print $1}')
  10. ./conv_log.sh $fname $logdate $outfile
  11. done < ./log_read.txt
  12. # eof
  13.  
  14. # -------------------------------
  15. #!/bin/bash
  16. # this file: conv_log.sh
  17. #
  18. logfile="$1"
  19. logdate="$2"
  20. outfile="$3"
  21. tmpfile="/tmp/energyout.txt"
  22. rm -f $tmpfile
  23. # if the logfile doesn't exist then bailout
  24. if [ ! -f $logfile ]; then
  25.    echo "Logfile doesn't exist, exiting..."
  26.    exit 3
  27. fi
  28. #
  29. cat $logfile |awk -F "," '{print $2}' > $tmpfile
  30. #
  31. kwday=$(perl -nle' $s += $_; END { printf "%.2f", $s*4/3600000 } ' $tmpfile)
  32. #
  33. echo "${logdate},${kwday}"
  34. echo "${logdate},${kwday}" >> $outfile
  35. #
  36. rm -f $tmpfile
  37. #
  38. # eof
  39. #
  40.  
  41. # input file (log_read.txt)
  42. /usr/local/etc/energy_meter_logs/01-12-2021.log
  43. /usr/local/etc/energy_meter_logs/02-12-2021.log
  44. /usr/local/etc/energy_meter_logs/03-12-2021.log
  45. /usr/local/etc/energy_meter_logs/04-12-2021.log
  46. /usr/local/etc/energy_meter_logs/05-12-2021.log
  47. /usr/local/etc/energy_meter_logs/06-12-2021.log
  48. /usr/local/etc/energy_meter_logs/07-12-2021.log
  49. /usr/local/etc/energy_meter_logs/08-12-2021.log
  50. /usr/local/etc/energy_meter_logs/09-12-2021.log
  51. /usr/local/etc/energy_meter_logs/10-12-2021.log
  52. /usr/local/etc/energy_meter_logs/11-12-2021.log
  53. /usr/local/etc/energy_meter_logs/12-12-2021.log
  54. /usr/local/etc/energy_meter_logs/13-12-2021.log
  55. /usr/local/etc/energy_meter_logs/14-12-2021.log
  56. /usr/local/etc/energy_meter_logs/15-12-2021.log
  57. /usr/local/etc/energy_meter_logs/16-12-2021.log
  58. /usr/local/etc/energy_meter_logs/17-12-2021.log
  59. /usr/local/etc/energy_meter_logs/18-12-2021.log
  60. /usr/local/etc/energy_meter_logs/19-12-2021.log
  61. /usr/local/etc/energy_meter_logs/20-12-2021.log
  62. /usr/local/etc/energy_meter_logs/21-12-2021.log
  63. /usr/local/etc/energy_meter_logs/22-12-2021.log
  64. /usr/local/etc/energy_meter_logs/23-12-2021.log
  65. /usr/local/etc/energy_meter_logs/24-12-2021.log
  66. /usr/local/etc/energy_meter_logs/25-12-2021.log
  67. /usr/local/etc/energy_meter_logs/26-12-2021.log
  68. /usr/local/etc/energy_meter_logs/27-12-2021.log
  69. /usr/local/etc/energy_meter_logs/28-12-2021.log
  70. /usr/local/etc/energy_meter_logs/29-12-2021.log
  71. /usr/local/etc/energy_meter_logs/30-12-2021.log
  72. /usr/local/etc/energy_meter_logs/31-12-2021.log
  73.  
  74. # output (date,kw)
  75. 01-12-2021,47.55
  76. 02-12-2021,51.82
  77. 03-12-2021,51.22
  78. 04-12-2021,50.33
  79. 05-12-2021,49.98
  80. 06-12-2021,50.47
  81. 07-12-2021,57.47
  82. 08-12-2021,53.84
  83. 09-12-2021,48.53
  84. 10-12-2021,47.59
  85. 11-12-2021,53.67
  86. 12-12-2021,37.75
  87. 13-12-2021,35.02
  88. 14-12-2021,35.08
  89. 15-12-2021,31.75
  90. 16-12-2021,36.60
  91. 17-12-2021,35.89
  92. 18-12-2021,43.98
  93. 19-12-2021,48.11
  94. 20-12-2021,46.83
  95. 21-12-2021,47.53
  96. 22-12-2021,52.63
  97. 23-12-2021,44.56
  98. 24-12-2021,38.98
  99. 25-12-2021,50.22
  100. 26-12-2021,54.20
  101. 27-12-2021,48.61
  102. 28-12-2021,43.36
  103. 29-12-2021,45.88
  104. 30-12-2021,36.24
  105. 31-12-2021,28.90
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement