Hi all,

Here is a small test which shows what happens:

limit=500000000; x=1; while [ $x -le $limit ]; do printf "%010d\n" $x;
x=$(( $x + 1)); done >bigfile.txt
while read line; do echo -e "TEST\t$line"; done >bug.txt

Basically the first line creates a big 5Gb text file containing 500
millions numbered lines (no problem here). Then the second line reads
this file line by line and adds a prefix 'TEST' to each.
The problem is that after the line 0195225788, it goes wrong and loops
on the following sequence:

TEST 0195225788
TEST 225778
TEST 0195225779
TEST 0195225780
TEST 0195225781
TEST 0195225782
TEST 0195225783
TEST 0195225784
TEST 0195225785
TEST 0195225786
TEST 0195225787
TEST 0195225788
TEST 225778

(so don't forget to stop the script, the bug.txt file will grow
infinitely!)

tested on an Ubuntu 11.04:
uname -a
Linux bloom 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC
2011 i686 i686 i386 GNU/Linux
bash --version
GNU bash, version 4.2.8(1)-release (i686-pc-linux-gnu)

I posted this issue yesterday in the Ubuntu forums, the problem was
confirmed by another user:
http://ubuntuforums.org/showthread.php?t=1808384

Regards
Erwan

Reply via email to