[Top][All Lists]
[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: |
Chet Ramey |
Subject: |
Re: [Help-bash] The best way to remove the last element of $@ |
Date: |
Thu, 07 Jun 2012 12:57:30 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20120601 Thunderbird/13.0 |
On 6/7/12 12:50 PM, 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?
>
> array=(a b c)
> printf "%s\n" address@hidden
> unset address@hidden
> printf "%s\n" address@hidden
I'm sure there are shorter ways, but the most straightforward is something
like
array=( "$@" )
unset last array element
set -- "address@hidden"
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/