[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to print all 3 char length string made whitespace {0..9} {a..z}

From: Marco Ippolito
Subject: Re: how to print all 3 char length string made whitespace {0..9} {a..z}
Date: Thu, 6 Aug 2020 00:46:08 -0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

On 02/08/2020 18:10, Mike Jonkmans wrote:
On Sun, Aug 02, 2020 at 03:43:05PM -0500, Peng Yu wrote:

As I said, I just want to generate all three character strings with
space, a..z, and 0..9 in bash. Otherwise, I will have to use a
different programming lang which I don't want to. I don't understand
why you ask this question.

On 8/2/20, Eli Schwartz <> wrote:
On 8/2/20 3:44 PM, Peng Yu wrote:

Is there a good way to generate all three-character strings made of
whitespace, {0..9} and {a..z}? Thanks.

You can always use multiple brace expansions together:

$ printf "<%s>\n" {{a..z}," ",{0..9}}

Though I'd first want to ask what you're really trying to do...
(I know, I know, you'll never tell us...)

Are you lookiung for this?
        echo {{a..z},\ ,{0..9}}{{a..z},\ ,{0..9}}{{a..z},\ ,{0..9}}

I don't want to know why.
Curiosity killed the cat.

Regards, Mike Jonkmans

I was going to recommend this:

e=({a..z} ' ' {0..9}); l=${#e[@]}; for ((i=0; i<l; i++)); do for ((j=0; j<l; j++)); do for ((y=0; y<l; y++)); do printf "${e[i]}${e[j]}${e[y]} "; done; done; done

to make the space complexity, or memory footprint, of it depend linearly rather than exponentially (even if just to the 3rd power), on the input, allowing more characters in the set to be permuted (e.g. Chinese characters) without segfaulting on malloc.

Marco Ippolito

reply via email to

[Prev in Thread] Current Thread [Next in Thread]