is there a more generic way to do it?
instead of $1/$2....to parse the whole line?
becouse like this I will have to change the script each time I use it for another file.
if you are sure that the no. of characters in the string is going to be constant, then you can first use sed to remove the blank spaces fron it and then use the awk substr() fn to print the required output.
while read LINE
do
echo |awk -v LIN="${LINE}" '{print substr(LIN,1,6)","substr(LIN,7,5)" ,"substr(LIN,13,4)","substr(LIN,17,3)" ,"substr(LIN,21,4)}'
done < INPUT
what I meant there is that if the no. of characters excluding spaces is constant, then you can first use sed to remove the spaces.
After that use
awk '{print substr($1,7,11) substr($1, m,n)........}' filename
once you remove the blank spaces , there will be only one field in each record so you can easily use substr on it.
for me if the data format could vary so much, you need to modify your script for every file I can't see how this could be made more generic.
The only thing is you can use $0 for parsing the whole line, but you will always have to change other parameters for the substr function