help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] The best way to remove the last element of $@


From: DJ Mills
Subject: Re: [Help-bash] The best way to remove the last element of $@
Date: Thu, 7 Jun 2012 13:21:39 -0400

On Thu, Jun 7, 2012 at 12:50 PM, Peng Yu <address@hidden> wrote:
> Hi,
>
> It is easy to remove the last element of a regular array. But the
> following pattern can not be applied to address@hidden Does anybody know what 
> is
> the best way to unset the last element?
>
> array=(a b c)
> printf "%s\n" address@hidden
> unset address@hidden
> printf "%s\n" address@hidden
>
> --
> Regards,
> Peng
>

set -- "${@:1:$#-1}"

It's a terribly inefficient operation, though. Why would you need to do this?

See http://mywiki.wooledge.org/BashFAQ/035 for some sane option
handling solutions



reply via email to

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