Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Removing an element from an array
- X-seq: zsh-users 26144
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Peter Slížik <peter.slizik@xxxxxxxxx>
- Subject: Re: Removing an element from an array
- Date: Mon, 2 Nov 2020 12:25:21 +0100
- Archived-at: <https://zsh.org/users/26144>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2020-11/CAN%3D4vMoAcip8q_zTm1-R-81d15OP9o6_Gyu7cvcpdbE-BLScVg%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-io1-f52.google.com) smtp.remote-ip=209.85.166.52; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=WUVnb/OWMzti/v3Uv0ilpUr/LwL7rCvSp/FhFSpnVjg=; b=pqaZ1x0jncUk8AZ21VXO5nqf4vk/N9jlP5cP/X0qOoA88Dd9VOZCov7OLtN86EJ1uM 3JgAdBzErXbTaNiFxxt1O000vZThOD3dq6EMtNtX+0oyr0kzfSzf4RJXBh45Z3MvRlcg r9KmdFo3bo6ZbqsR4KT+cbbne/7eA/MiTPxlFnXQVF3erLlspXgThXCLEBQzYYBVatVx 4lFjBzQBVid9dQ90MTQ8iY3FQfUvW9p789wHQ1gTUA/MiRgeL3cY7KjfSDEoQAy6AbN5 gGSAeE8TZhbgulju/LQVDDllu4Xa0B/tbhbJVKZBhA6jEtU+zAZhhET3pPFQtbwte9Zh Zaqw==
- In-reply-to: <CAC-uhUCeckrWr-F-hsXtktYO8G8Ts1=Opyg4S0Xb9Y4bMKnCKg@mail.gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-users>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-users.zsh.org>
- List-owner: <mailto:zsh-users-request@zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-users>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-users>
- References: <CAC-uhUCeckrWr-F-hsXtktYO8G8Ts1=Opyg4S0Xb9Y4bMKnCKg@mail.gmail.com>
- Sender: zsh-users-request@xxxxxxx
On Mon, Nov 2, 2020 at 12:11 PM Peter Slížik <peter.slizik@xxxxxxxxx> wrote:
>
> I would like to remove an element from an array - actually a path from the $path variable. After some googling, I've discovered the ${array:|excl} syntax.
>
> Here is my code:
>
> excl=($path_to_remove)
> export path=${path:|excl}
This is pretty close. Here's the correct syntax:
excl=($path_to_remove)
path=(${path:|excl})
However, if you want to remove just one element, there is a simpler way:
path=(${path:#$path_to_remove})
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author