Hi,
I have the following data in the format as shown(note: there are more than 1 blank spaces between each field and the spaces are not uniform, meaning there can be one blank field between field1 and field2 and 3 spaces between field3 and field4):
________________________________________
num1a num2a num3a num4a num5a
num1b num2b num4b
num2c num3c num4c num5c
num2d num3d num4d num5d
num1e num2e num3e num4e num5e
num1f num5f
________________________________________
i need to include ; as the field delimited and the required output is:
________________________________________
num1a;num2a;num3a;num4a;num5a
num1b;num2b;;num4b;
;num2c;num3c;num4c;num5c
;num2d;num3d;num4d;num5d
num1e;num2e;num3e;num4e;num5e
num1f;;;;num5f
________________________________________
I tried using
sed -e 's/ */;/g'
but it will take consecutive blank fields as one blank field. Can anyone help?
I have the following data in the format as shown(note: there are more than 1 blank spaces between each field and the spaces are not uniform, meaning there can be one blank field between field1 and field2 and 3 spaces between field3 and field4):
________________________________________
num1a num2a num3a num4a num5a
num1b num2b num4b
num2c num3c num4c num5c
num2d num3d num4d num5d
num1e num2e num3e num4e num5e
num1f num5f
________________________________________
i need to include ; as the field delimited and the required output is:
________________________________________
num1a;num2a;num3a;num4a;num5a
num1b;num2b;;num4b;
;num2c;num3c;num4c;num5c
;num2d;num3d;num4d;num5d
num1e;num2e;num3e;num4e;num5e
num1f;;;;num5f
________________________________________
I tried using
sed -e 's/ */;/g'
but it will take consecutive blank fields as one blank field. Can anyone help?