[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] The best way to get the last element of $@
From: |
Eric Blake |
Subject: |
Re: [Help-bash] The best way to get the last element of $@ |
Date: |
Thu, 19 Mar 2015 10:58:45 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
On 03/19/2015 10:49 AM, Peng Yu wrote:
> Hi,
>
> There are many ways of getting the last element of address@hidden Does anybody
> know what might be the best way to get the last element of address@hidden
> Thanks.
Here's one way that requires no subshells (yes, it uses eval, but this
is one case where we are safe from eval doing anything evil):
# set $last to the last member of $@
eval printf -v last %s "address@hidden"
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature