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: Greg Wooledge
Subject: Re: [Help-bash] The best way to remove the last element of $@
Date: Thu, 7 Jun 2012 12:56:17 -0400
User-agent: Mutt/1.4.2.3i

On Thu, Jun 07, 2012 at 11:50:47AM -0500, Peng Yu 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?

1) Rewrite your application so that you are using "shift" instead of
   running through the positional parameters backwards.

2) Copy the positional parameters to an array and then use unset on the
   array.

3) Use the "range" notation to generate a list of all the positional
   parameters except the last one, and then reassign the lot of 'em.

That's in order of preference.



reply via email to

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