Pegun
Golden Member
I'm trying to take a file which is a weblog and output certain statistics about it. The input (first line) is 23/Dec/2007:15:08:08
I use the following code to get just the date and compare it to the final date in the file:
varstartdate=$(cut -f4 -d " " "access_log.1998-12" | head -1 | sed -e 's/\[/\ /g' -e 's/\:/\ /g' -e 's/\//\ /g' | cut -f2 -d " ")
varenddate=$(cut -f4 -d " " "access_log.1998-12" | tail -1 | sed -e 's/\[/\ /g' -e 's/\:/\ /g' -e 's/\//\ /g' | cut -f2 -d " ")
if [$varstartdate > $varenddate]
then $varenddate=$varenddate + 30
fi
#vartotaldays=$varenddate - $varstartdate
#echo "Total number of days = " $vartotaldays
I keep getting a "[23 command not found" error. Because I'm not used to bash scripting I have no idea what the problem is. Can anyone help?
I use the following code to get just the date and compare it to the final date in the file:
varstartdate=$(cut -f4 -d " " "access_log.1998-12" | head -1 | sed -e 's/\[/\ /g' -e 's/\:/\ /g' -e 's/\//\ /g' | cut -f2 -d " ")
varenddate=$(cut -f4 -d " " "access_log.1998-12" | tail -1 | sed -e 's/\[/\ /g' -e 's/\:/\ /g' -e 's/\//\ /g' | cut -f2 -d " ")
if [$varstartdate > $varenddate]
then $varenddate=$varenddate + 30
fi
#vartotaldays=$varenddate - $varstartdate
#echo "Total number of days = " $vartotaldays
I keep getting a "[23 command not found" error. Because I'm not used to bash scripting I have no idea what the problem is. Can anyone help?