while read line do

I have a .dat file like below eg: sample.DAT

21111111110000652 B86860003OLFXXX000000120081227
21111111110000652 B86860003ODL-SP000000220081227
21111111110000652-B94030001ODL-CH000000320081227
22222222220000653-B94030001OLFXXX000001120081227
23333333330000654-E71060001OLFXXX000001220081227
24444444440000655 E71060002OLFXXX000001420081227
24444444440000655 E71060002ODL-SP000001520081227
 
111111111 is a ssno with 3 records self(amt is 0000001), spouse(amt is 0000002),child (amt is 0000003)
222222222 is a ssno with just 1 record self
333333333 is a ssno with just 1 record self
444444444 is a ssno with just 2 record self(amt is 0000014),spouse(amt is 0000015)

after reading the above file in the WHILE READ LINE DO loop

Basically i am creating 2 more new columns amt_1 and amt_2 in the flat file (sampleout.txt) seperating if any records exists with spouse or child.
for eg: record 21111111110000652 we have 3 records self,spouse & child, i need to create only one record seperating the spouse or child record exists with the amount coulumns seperate spouse amt is 0000002 & child amt is 0000003 like wise the loop should check

21111111110000652 B86860003OLFXXX000000120081227 0000002 0000003
22222222220000653-B94030001OLFXXX000001120081227
23333333330000654-E71060001OLFXXX000001220081227
24444444440000655 E71060002OLFXXX000001420081227 0000015

-----
-----
...etc

Any help is appreciated.

Thanks in adv.

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

No reply on this...