Article View: linux.debian.user
Article #279Bash: brace expansion [was: Bash: check if a value is into an array]
From: tomas
Date: Fri, 23 Oct 2026 15:30
Date: Fri, 23 Oct 2026 15:30
58 lines
3413 bytes
3413 bytes
--m5eLFotwSlRBJn1Q
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Fri, Oct 23, 2026 at 05:18:37PM +0300, Anssi Saari wrote:
> The Wanderer <wanderer@fastmail.fm> writes:
>=20
> > $ 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'.
>=20
> 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.
>=20
> So echo {01..10} outputs 01 02 03 04 05 06 07 08 09 10.
And it does letters:
echo {a..l}
=3D> a b c d e f g h i j k l
=2E..and it composes...
echo xy{1..3}zzy
=3D> xy1zzy xy2zzy xy3zzy
=2E..in a Cartesian way...
echo {1..3}{x..z}
=3D> 1x 1y 1z 2x 2y 2z 3x 3y 3z
echo {1..3}{x..z}{2..3}
=3D> 1x2 1x3 1y2 1y3 1z2 1z3 2x2 2x3 2y2 2y3 2z2 2z3 3x2 3x3 3y2 3y3 3z=
2 3z3
(I get reminiscences of APL)
(OK, OK, I'm stopping now ;-)
Enjoy
--=20
t
--m5eLFotwSlRBJn1Q
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCatt7HAAKCRAFyCz1etHa
RhyoAJ0XHYBrzFja0mceo4bHFxYG0U0h2gCfd1uKIVOPNxyi+zx7ZTJ2TlW2gHc=
=OEc3
-----END PGP SIGNATURE-----
--m5eLFotwSlRBJn1Q--
Technical Details
Message-ID:
<NRpnr-7pXh-17@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomodReferences:
<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>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!diesel.cu.mi.it!bofh.it!news.nic.it!robomod From: <tomas@tuxteam.de> Newsgroups: linux.debian.user Subject: Bash: brace expansion [was: Bash: check if a value is into an array] Date: Fri, 23 Oct 2026 17:30:01 +0200 Message-ID: <NRpnr-7pXh-17@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> X-Mailbox-Line: From debian-user-request@lists.debian.org Fri Oct 23 15:20:16 2026 Old-Return-Path: <tomas@tuxteam.de> X-Amavis-Spam-Status: No, score=-2.1 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] autolearn=ham autolearn_force=no X-Policyd-Weight: using cached result; rate: -4.6 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="m5eLFotwSlRBJn1Q" Content-Disposition: inline X-Mailing-List: <debian-user@lists.debian.org> archive/latest/832589 List-ID: <debian-user.lists.debian.org> List-URL: <https://lists.debian.org/debian-user/> List-Archive: https://lists.debian.org/msgid-search/att7I4GKv9T6vB22@tuxteam.de Approved: robomod@news.nic.it Lines: 58 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Fri, 23 Oct 2026 17:20:03 +0200 X-Original-Message-ID: <att7I4GKv9T6vB22@tuxteam.de> 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>