Estou escrevendo um script no bash. Minha saída abaixo está errada. Os dados de teste que estou tirando, fazem com que todas as conexões permitidas e negadas devam estar no tempo "00", mas para cada dia que eu rastejo, elas vão para a próxima hora. Eu tenho meu código abaixo e saio da amostra na parte inferior. Pode me ajudar? Está me dando dor de cabeça.
#!/bin/bash
echo "MEGA CRAWLER BY DA INTERNS" > Result
echo "Enter the month of the file you're trying to read"
echo "If month is one number enter one number if two numbers enter two numbers"
read M
#case staement changes M input into a month an reassigns single digit months into double digit
if [[ $M -lt 13 && $M -gt 0 ]]
then
case "$M" in
"1") month="Jan" ; M="01" ; Dlim="31"
;;
"2") month="Feb" ; M="02" ; Dlim="29"
;;
"3") month="Mar" ; M="03" ; Dlim="31"
;;
"4") month="Apr" ; M="04" ; Dlim="30"
;;
"5") month="May" ; M="05" ; Dlim="31"
;;
"6") month="Jun" ; M="06" ; Dlim="30"
;;
"7") month="Jul" ; M="07" ; Dlim="31"
;;
"8") month="Aug" ; M="08" ; Dlim="31"
;;
"9") month="Sep" ; M="09" ; Dlim="30"
;;
"10") month="Oct" ; Dlim="31"
;;
"11") month="Nov" ; Dlim="30"
;;
"12") month="Dec" ; Dlim="31"
;;
esac
else
echo "Please make sure to enter a valid month."
read M
fi
echo -e ""
echo "Enter the year of the file you're trying to read"
read Y
echo -e ""
for D in $(seq -f "%02g" 1 5); do
File=($(find -name "traffic_$M-$D-$Y"))
echo "-------------------------DAY $D-------------------------" >> Result
for i in $(seq -f "%02g" 0 23); do
grep "$month $i" $File > TempOutput
countAllow=($(grep -c "allow" TempOutput))
countDeny=($(grep -c "deny" TempOutput))
echo -e "$countAllow connections allowed at $i time" >> Result
echo -e "$countDeny connections denied at $i time\n" >> Result
rm TempOutput
done
done
-------------------------DAY 01-------------------------
0 connections allowed at 00 time
0 connections denied at 00 time
77 connections allowed at 01 time
25 connections denied at 01 time
0 connections allowed at 02 time
0 connections denied at 02 time
-------------------------DAY 02-------------------------
0 connections allowed at 00 time
0 connections denied at 00 time
0 connections allowed at 01 time
0 connections denied at 01 time
76 connections allowed at 02 time
26 connections denied at 02 time