On Sat, Feb 01, 2014 at 05:36:17PM +0100, Mathieu Malaterre wrote: > #!/bin/bash > > for i in {0..4294967295}; do > echo $i > done
Others said not to do that. They are correct, but they didn't tell you what to do instead. for ((i=0; i<=4294967295; i++)); do echo $i done The brace expansion form actually expands to the full list of strings, all at once, which means they are all stored in memory at once. Most computers don't have that much memory (something like 40 GB to hold your 4 billion strings, of variable length from 2 to 11 bytes each). The C-style for loop doesn't generate them all at once, so it only uses a few bytes of memory.