#!/bin/bash
#title           :clockoffset.sh
#description     :This script processes the sc_offset.dat file into a more readable format for logstash to digest.
#author          :Vincent Mahathirash
#date            :2017-09-08
#version         :1.0
#usage           :bash mkscript.sh
#bash_version    :4.1.2(1)-release
#================================================================================================================

sed 1d $1 | while IFS=' ' read -r doy offset slope || [[ -n "$line" ]]; do
  if [ -z "$doy" ]; then
    break
  fi
  if [ "$slope" ]; then
    line="$doy $offset $slope"
  else
    line="$doy $offset"
  fi
  line=$(echo "$line" | tr -s " ")
  #echo "$line" >> /aim/logs/elk/clockoffset.log
  echo "$line" >> /aim/sds/elk/scripts/clockoffset.log
done
echo "stopped"
