bash oom problem
Tony Nelson
tonynelson at georgeanelson.com
Mon Oct 5 03:58:07 UTC 2009
On 09-10-04 06:17:20, Sharpe, Sam J wrote:
> 2009/10/4 psmith <psmith at fedoraproject.org>:
> > hi list, whilst trying to run this bash command
> >
> > for w in {A..Z}{A..Z}{A..Z}{A..Z}{A..Z}{A..Z}{A..Z}{A..Z} ;do echo
> $w;done >
> > wl1
>
> Consider that for a second...
>
> You are trying to generate a list of all possible combinations of an
> 8 character word composed of only uppercase letters - that's 26^8
> combinations (208 Billion). Each word is 8 bytes long, which I make
> to be 1670616516608 bytes... or to put it another way, 1.5 TB
>
> So, you've got 4 GB of virtual memory and you are trying to fit an
> 1555GB array into it. Simple mathematics says no. Dumping the
> arguments before it dies is pointless, because it hasn't even got as
> far as expanding arguments yet.
>
> You need to think of another was to do this and I humbly suggest that
> Bash should not be high on your list.
Bash should be OK if Pathname Expansion is used instead of the more
general Brace Expansion:
$ for w in [[:upper:]][[:upper:]][[:upper:]][[:upper:]][[:upper:]]
[[:upper:]][[:upper:]][[:upper:]] ; do echo $w ; done
However, if there are no matches, the match string will be tried unless
the shell options failglob is unset and nullglob is set:
$ ( shopt -s nullglob ; shopt -u failglob ; for w in [[:upper:]]
[[:upper:]][[:upper:]][[:upper:]][[:upper:]][[:upper:]][[:upper:]]
[[:upper:]] ; do echo $w ; done )
(Sorry for the wrapping.)
--
____________________________________________________________________
TonyN.:' <mailto:tonynelson at georgeanelson.com>
' <http://www.georgeanelson.com/>
More information about the fedora-list
mailing list