- 14:57 root@
- # cat seservice13783 | sort -k 2
- "2020-10-18T11:35:57.970451478Z 158.177.177.93"
- "2020-10-19T05:03:23.29479408Z 158.177.177.93"
- "2020-10-19T22:30:49.359389161Z 158.177.177.93"
- "2020-10-20T15:58:14.699997636Z 158.177.177.93"
- "2020-10-21T09:25:40.787000154Z 158.177.177.93"
- "2020-10-21T10:32:38.380137936Z 158.177.177.93"
- "2020-10-21T10:32:38.440539359Z 158.177.177.93"
- 15:23 root@
- # date +"%s" -d 2020-10-28T00:07:02.630071428Z
- cat seservice13783_sort_k2 | awk '{ print substr( $1, 2)
- 15:36 root@
- # echo "2020-10-28T00:07:02.630071428Z" | date +"%s" -d -
- previous_timestamp=0
- while read -r line; do
- date_string=$( echo $line | awk '{print substr($1, 2)}' ) #this maybe can be leaner
- ip_addr=$(echo $line | awk '{ print $2 }' )
- date_timestamp=$( date +"%s" -d $date_string ) #getting the date from standardin with - doesn't yield good results
- hours_difference=$( echo "scale=2; ( ${date_timestamp} - ${previous_timestamp} ) / 3600 " | bc )
- #echo $date_timestamp
- previous_timestamp=$date_timestamp
- echo "${hours_difference} ${date_string} ${ip_addr}"