🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.user
Article #305

Re: Bash: brace expansion [was: Bash: check if a value is into an array]

#305
From: Franco Martelli
Date: Mon, 26 Oct 2026 16:10
56 lines
5150 bytes
On 23/10/26 at 17:20, tomas@tuxteam.de wrote:
> On Fri, Oct 23, 2026 at 05:18:37PM +0300, Anssi Saari wrote:
>> The Wanderer <wanderer@fastmail.fm> writes:
>>
>>> $ echo {1..10}
>>>
>>> , the 'for i in {1..10}; do' is exactly equivalent to 'for i in 1 2 3 4
>>> 5 6 7 8 9 10 ; do'.
>>
>> The coolest thing about this brace expansion is that you can even get
>> the numbers zero padded for a fixed width, like maybe for filenames or
>> tabular data.
>>
>> So echo {01..10} outputs 01 02 03 04 05 06 07 08 09 10.
> 
> And it does letters:
> 
>      echo {a..l}
>      => a b c d e f g h i j k l
> 
> ...and it composes...
> 
>      echo xy{1..3}zzy
>      => xy1zzy xy2zzy xy3zzy
> 
> ...in a Cartesian way...
> 
>      echo {1..3}{x..z}
>      => 1x 1y 1z 2x 2y 2z 3x 3y 3z
> 
>      echo {1..3}{x..z}{2..3}
>      => 1x2 1x3 1y2 1y3 1z2 1z3 2x2 2x3 2y2 2y3 2z2 2z3 3x2 3x3 3y2 3y3 3z2 3z3
> 
> (I get reminiscences of APL)
> 
> (OK, OK, I'm stopping now ;-)
> 
> Enjoy

Why splitting in multiple lines a sequence doesn't work:

~$ IFS=$'\n' echo {001..136}

I would expect:

001
002
003
...

instead I got the sequence expanded on a single line, have I to use "tr" 
forcibly?

Kind regards,
-- 
Franco Martelli
Technical Details
Message-ID: <NSvqO-82wf-1@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomod
References: <NQFND-6ZMU-9@gated-at.bofh.it> <NQG6Z-703J-7@gated-at.bofh.it> <NQJod-71PP-13@gated-at.bofh.it> <NQJRf-729Y-1@gated-at.bofh.it> <NR1br-7bQc-11@gated-at.bofh.it> <NRohI-7plk-23@gated-at.bofh.it> <NRohI-7plk-21@gated-at.bofh.it> <NRpnr-7pXh-17@gated-at.bofh.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomod
From: Franco Martelli <martellif67@gmail.com>
Newsgroups: linux.debian.user
Subject: Re: Bash: brace expansion [was: Bash: check if a value is into an  array]
Date: Mon, 26 Oct 2026 17:10:02 +0100
Message-ID: <NSvqO-82wf-1@gated-at.bofh.it>
References: <NQFND-6ZMU-9@gated-at.bofh.it> <NQG6Z-703J-7@gated-at.bofh.it> <NQJod-71PP-13@gated-at.bofh.it> <NQJRf-729Y-1@gated-at.bofh.it> <NR1br-7bQc-11@gated-at.bofh.it> <NRohI-7plk-23@gated-at.bofh.it> <NRohI-7plk-21@gated-at.bofh.it> <NRpnr-7pXh-17@gated-at.bofh.it>
X-Original-To: debian-user@lists.debian.org
X-Mailbox-Line: From debian-user-request@lists.debian.org  Mon Oct 26 16:06:45 2026
Old-Return-Path: <martellif67@gmail.com>
X-Amavis-Spam-Status: No, score=-1.849 tagged_above=-10000 required=5.3
 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
 DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham autolearn_force=no
X-Policyd-Weight: using cached result; rate: -5.5
X-Gm-Message-State: AFq9FYLcgWinJ6o7KRcJv3jjckeu6nPh20d+LTf4ZNmE+75GbyIjwfu3
	G27pH2YHgrHlDzGz5ArZUuZF2X3bUTcJ0hwWJO925STnNWQU2ku5ovZG8CVNKQ==
X-Gm-Gg: AYBFou2FzyS6nD+GNNFepO4q4WdZdSPycFPm0DVO+jYs4xFdgbsc2g9mSM5oBXAVO8W
	Jd8XvdzSwvzkXjDxoLq3qD8dqjHEsOOu+G+zg3c37TfiU8TNhc20tfOHFtGyvY6JWv3fj8z4wE3
	RUNnZyxNdXimhYre4JWVcR1InoERaxUmvWJS99zENOXikpiLGQx2wZxnt1+Ij/lTdD+2wDPJz5R
	ztfPogc810cjDEZcuZb1I50bJWWj6LO22IKbRXZAXHwyS84Gg+1ltHO+zzDRJfFG/xcs54U9Ujj
	IzH6bQU+Et9KIw28q9mOuL8wvL6Y7hjHbyxfezfo9QgIFrRg/XOHyTD/L+BTs47/kXQA6eNKWO0
	Nwf75NHB+9AH6xUGR0WpCDzRtSNJxFmawXu6q1Q9txwIwO5aWzXoJ0B4wVV+C6/xgDXFZN5Uh5m
	nmIlf1TH9+XR5sTLiODj+xg6/4JW+Yoyed6jqLSaZ3P1Sz/vzMz5BICJuHuXm9OYMrpq1R5AGC3
	MZhzyUS6V6jTeOf5kd38SRH7oH1vaO2mPBZNZn+lk349g2ZUNA55cV+MTJQIImrycvfnqfMMyyx
	l6DCvq8L3F6p3yE=
X-Received: by 2002:a05:600c:45c4:b0:49e:6581:7baf with SMTP id 5b1f17b1804b1-4a7bfec4e49mr2799215e9.2.1793030791277;
        Mon, 26 Oct 2026 09:06:31 -0700 (PDT)
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
Autocrypt: addr=martellif67@gmail.com; keydata=
 xjMEXwx9ehYJKwYBBAHaRw8BAQdA8CkGKYFI/MK9U3RPhzE5H/ul7B6bHu/4BIhTf6LLO47N
 J0ZyYW5jbyBNYXJ0ZWxsaSA8bWFydGVsbGlmNjdAZ21haWwuY29tPsKWBBMWCAA+FiEET9sW
 9yyU4uM6QbloXEn0O0LcklAFAmhyroACGwMFCQ0ncuYFCwkIBwIGFQoJCAsCBBYCAwECHgEC
 F4AACgkQXEn0O0LcklAHVwD9H5JZ52g292FD8w0x6meDD8y/6KkNpzuaLHP6/Oo8kAIBAJsh
 aMB9LdCBJTMtnxU8JTHtAoGOZ/59UJWeZIkuWJUNzjgEXwx9ehIKKwYBBAGXVQEFAQEHQNP5
 V2q0H0oiJu89h1SSPgQDtkixXvUvRf1rNLLIcNpPAwEIB8J+BBgWCAAmFiEET9sW9yyU4uM6
 QbloXEn0O0LcklAFAmhyroACGwwFCQ0ncuYACgkQXEn0O0LcklASVwEAoEkHMEU7mHc0zmAu
 D2R1PYsDh9+3wQeied5PrF+HdakBAOeSGsf40GBew5umZuM59I04d1uXYAXGMP+jGN2RUtMA
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Mailing-List: <debian-user@lists.debian.org> archive/latest/832622
List-ID: <debian-user.lists.debian.org>
List-URL: <https://lists.debian.org/debian-user/>
List-Archive: https://lists.debian.org/msgid-search/e5212026-5fa3-4d52-8ab6-19befb78fc56@gmail.com
Approved: robomod@news.nic.it
Lines: 56
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Mon, 26 Oct 2026 17:06:29 +0100
X-Original-Message-ID: <e5212026-5fa3-4d52-8ab6-19befb78fc56@gmail.com>
X-Original-References: <fb4588c5-2637-4714-81e6-791a9260afbd@gmail.com>
 <20261021150743.GA21484@wooledge.org>
 <b397ac30-dbff-4822-b314-c6cc97dc0df8@gmail.com>
 <20261021190429.GA28455@wooledge.org>
 <02f8c2b4-80ec-4f0a-a277-3f1c80acd476@gmail.com>
 <6ADA15E3.2000204@fastmail.fm> <sm0se1wfqki.fsf@lakka.kapsi.fi>
 <att7I4GKv9T6vB22@tuxteam.de>