Unfold the data from a input file and write to a file

I am working on a script to unfold data for each column from a specific line of data and write output in a single line.

Input data looks like this.

2011-09-26 INF UM_10 UserMana Starting synchronization for security domain
14:37:31       080   gementSe [12345].
                     rvice

I prepared the script to unfold the above data

#!/usr/bin/ksh
while read mDate mRest; do
  if [[ ${#mDate} -eq 10 ]]; then
    if [[ "${mOut}" != "" ]]; then
      echo ${mOut}
    fi
    mOut=''
  fi
  mOut=${mOut}' '${mDate}' '${mRest}
done < Inp_File
if [[ "${mOut}" != "" ]]; then
  echo ${mOut}
fi

The problem with this script is it simply cuts the data from 2nd and 3rd lines and attaches to the first line.

2011-09-26 INF UM_10 UserMana Starting synchronization for security domain 08:45:10 080 gementSe [12345]. rvice

But I want the data to be like this:

2011-09-26 14:37:31 INF UM_10080 UserManagementService Starting synchronization for security domain [12345].

Thanks,
Bob

awk '{a=a FS substr($0,1,10);b=b FS substr($0,12,3);c=c FS substr($0,16,5);d=d FS substr($0,22,8);e=e FS substr($0,31)}
    END{gsub(/ *$/,"",a);gsub(/ /,"",b);gsub(/ /,"",c);gsub(/ /,"",d);print a,b,c,d,e}' infile
1 Like

Thanks. Let me try and get back to you in case of any issues.

Thanks,
Bob