|
From: | Léa Gris |
Subject: | Re: Crash on large brace expansion |
Date: | Fri, 16 Jul 2021 00:24:10 +0200 |
User-agent: | Telnet/1.0 [tlh] (PDP11/DEC) |
Le 15/07/2021 à 21:23, Greg Wooledge écrivait :
On Thu, Jul 15, 2021 at 05:28:04PM +0200, Léa Gris wrote:Le 15/07/2021 à 16:36, Gabríel Arthúr Pétursson écrivait :Hi all, Executing the following results in a fierce crash: $ bash -c '{0..255}.{0..255}.{0..255}.{0..255}'Brace expression expands all the value in memory. Here you are actually telling Bash to expand 256⁴ or 4294967296 42 Billion entries.4.2 billion, but who's counting? :-)
Ah yes, my billions or off by ten folds.Here is a single-loop version to absolve me of my arithmetical overstatement:
a=0 while [ $a -lt 4294967296 ]; do printf '%d.%d.%d.%d\n' \ $((a >> 24)) $((a >> 16 & 255)) $((a >> 8 & 255)) $((a & 255)) a=$((a + 1)) done -- Léa Gris
[Prev in Thread] | Current Thread | [Next in Thread] |