bug-bash
[Top][All Lists]
Advanced

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

last element of an array


From: Nathan Coulter
Subject: last element of an array
Date: Thu, 24 May 2007 14:17:35 +0000

The syntax I'm currently using to access the last element of an array looks a 
little evil:

>arr=( one two three )
>echo ${arr[$((${#arr[@]}-1))]}
three

If there is not currently a friendlier syntax for this, might I suggest:

${arr[-1]}

-- 
Poor Yorick




reply via email to

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