# program in loop.

**URL:** <https://community.unix.com/t/program-in-loop/251973>\
**Category:** Shell Programming and Scripting\
**Created:** [October 23, 2009, 4:31pm UTC](https://community.unix.com/t/program-in-loop/251973 "2009-10-23T16:31:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kshuser](https://community.unix.com/letter_avatar/kshuser/32/5_5575768a8748004e209b776fc1b2916d.png) [@kshuser](https://community.unix.com/u/kshuser)\
**Post date:** [October 23, 2009, 4:31pm UTC](https://community.unix.com/t/program-in-loop/251973/1 "2009-10-23T16:31:34Z")

</div>

eg: sample.dat

21111111110000652 B86860003OLFXXX0000001\_20081227  
21111111110000652 B86860003ODL-SP0000002\_20081227  
21111111110000652-B94030001ODL-CH0000003\_20081227  
22222222220000653-B94030001OLFXXX0000011\_20081227  
23333333330000654-E71060001OLFXXX0000012\_20081227  
24444444440000655 E71060002OLFXXX0000014\_20081227  
24444444440000655 E71060002ODL-SP0000015\_20081227  
.....  
.....

I Want to write a program in ksh script in such a way (while read line do) that the out txt file should look like below

outfile.txt

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

thx

---

<div class="post-metadata">

**Author:** ![cfajohnson](https://community.unix.com/user_avatar/community.unix.com/cfajohnson/32/16669_2.png) [@cfajohnson](https://community.unix.com/u/cfajohnson)\
**Post date:** [October 23, 2009, 4:35pm UTC](https://community.unix.com/t/program-in-loop/251973/2 "2009-10-23T16:35:30Z")

</div>

What is the algorithm to transform the input to the output?

What do you have to do to it?

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/5_5575768a8748004e209b776fc1b2916d.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [October 23, 2009, 4:36pm UTC](https://community.unix.com/t/program-in-loop/251973/3 "2009-10-23T16:36:16Z")

</div>

Hi.

Is there any chance you might tell us where 0000002, etc. might come from?

---

<div class="post-metadata">

**Author:** ![kshuser](https://community.unix.com/letter_avatar/kshuser/32/5_5575768a8748004e209b776fc1b2916d.png) [@kshuser](https://community.unix.com/u/kshuser)\
**Post date:** [October 23, 2009, 4:39pm UTC](https://community.unix.com/t/program-in-loop/251973/4 "2009-10-23T16:39:04Z")

</div>

Pls read my earlier posting on this.

> **[while read line do](https://www.unix.com/shell-programming-and-scripting/122011-while-read-line-do.html)**
>
> I have a .dat file like below eg: sample.DAT pre { overflow:scroll; margin:2px; padding:15px; border:3px inset; margin-right:10px; } Code: 21111111110000652 B86860003OLFXXX000000120081227 211111111100 | The UNIX and Linux Forums

> [@scottn](#):
>
> Hi.
> 
> Is there any chance you might tell us where 0000002, etc. might come from?

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/5_5575768a8748004e209b776fc1b2916d.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [October 23, 2009, 4:40pm UTC](https://community.unix.com/t/program-in-loop/251973/5 "2009-10-23T16:40:12Z")

</div>

Sorry. I didn't realise that this was a double post!!

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [October 23, 2009, 5:46pm UTC](https://community.unix.com/t/program-in-loop/251973/6 "2009-10-23T17:46:02Z")

</div>

Bumping up posts or double posting is not permitted in these forums.

Please read the [rules](http://www.unix.com/misc.php?do=cfrules), which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
