Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: for loop with variable
- X-seq: zsh-users 30652
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: for loop with variable
- Date: Mon, 11 May 2026 19:11:55 +0200
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fAJqVZUKUAmRXkv3BoG7778o2WgrBYX5Im9vNpui/EI=; fh=jPiVBPZEfwBf151+XrsNuwNUZll4fQOLSzRxlVE23MQ=; b=ZS11J7yHdOqUKRW/S2Wyf4S8wxkrYCTlrSq+2su0Iz1/m2lfN6kHkSHSHUokvfOJ+H lS8493poOS/Y290VE2wBDI9b0P1GGdsdPL1enYiWGuAFmZs3PAHvkNQwDwf3JE/bzlgw DDaTRj/LBsYalvka1s+lIywr0FWdgC5xtBD3u9p3fVztfU1CDjosHHnDG9OMjbswx6Ea +LWQuPb1GXNtWnG7m3E/XTprETQcH5mNNp3hiWtN5eOpqMnaEbgeuJV4KkqID+f78v5F ume4y2zjlN/ue7vrnzG/9nEaVfK2254Y5FlfqTmyJLj5RYD0SBY0/ep9uSiNT9DCTCTV o9cg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1778519527; cv=none; d=google.com; s=arc-20240605; b=LUSSwnvNoJ9jxvLj/jteAu7UZ/qz1IZcQ5A1xx0z5osWP9biyzgUpGAKZtL0N9qyGD XZp9HSb8coEToWPt9/1sf33JKQWq66ugIB/1QkT0Ho/pfLLR/NVGGFSkSIPdd6Itpx6T 8Q/JSEuYaK1oUvChdFFCVhGFCzAeGwl7Dsw12qJcFOO+Crqk4Is8jC+mu29aVIGSMEFZ j6yIOMU01E9yLqM8WnuDSgEiRE3OBrXNJg8GYwDBEAHM/KCbNENzvacqcElbg/hOpFS4 e7g3ZVuXqC5nmWEkRp9A0CMeiAMpuOUyJO4oCR41jcvq5/UjyQ2WX4cjvLrMxgSbffF3 QYDw==
- Archived-at: <https://zsh.org/users/30652>
- In-reply-to: <a94bb2a4-b05c-4e22-97c7-a44ccd957e73@eastlink.ca>
- List-id: <zsh-users.zsh.org>
- References: <a94bb2a4-b05c-4e22-97c7-a44ccd957e73@eastlink.ca>
On Mon, May 11, 2026 at 6:45 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> % var=" a b c "
>
> % for aa in $=var; do echo $aa; done
> a
> b
> c
>
> % for aa in [a-c]; do echo $aa; done
> c
>
> ... In the last 'for' it wants to find files whereas in the previous it knows it's looking at text. Could the previous be done on one line? That is, the range '[a-c]' would be understood to be just text, not a file glob?
{a..c} expands to a b c. You can iterate over that.
Roman
Messages sorted by:
Reverse Date,
Date,
Thread,
Author