and a supplier to check the data, the other side is the gmt+0 time zone, our report default Beijing time, can not be modified to GMT0,
When you export data in Excel to Excel by hour, and then to a text file, the shell turns to GMT0 for statistics:
Pre-treatment:
The time is converted to "2016-05-01-00:08:00" format data, which facilitates the comparison of timestamps.
Remove invalid "," and "$" symbols to facilitate shell text processing.
Solve the problem of the day, and then loop through the script to resolve multiple days.
# for I in ' seq 20160501 20160518 ' , do sh tongji.sh "$i";
#!/bin/bash#test. Sh
Zone=8 Day=20160518if[ $1!=" "] ; Then Day=$1fiTime_begin=`Date-D"+ $zone Hour $day"+"%y-%m-%d%h:%m:%s"' Time_end=`Date-D"+ $zone hour +1 day $day"+"%y-%m-%d%h:%m:%s"`Echo "Time_begin is: $time _begin, Time_end is $time _end"filename="May-1-18-cost-imp.txt"Cat "$filename"|awk-F"\ t" '{ if($3>="'"$time _end"'"|| $3<"'"$time _begin"'") {next; }Else{print $3,$ the } if( $ the!="-") { cost+= $ the } if( $7!="-") {Impress+= $7}}end{print impress, cost}'
Shell statistics GMT0 time Zone data