[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Remove an empty (null) element in an indexed array
From: |
Jerry |
Subject: |
[Help-bash] Remove an empty (null) element in an indexed array |
Date: |
Wed, 24 Apr 2013 17:28:23 -0400 |
I have been playing around with a few ways to remove an empty or null
element in an indexed array but nothing seems to works as expected.
Assume array: declare -a FOO=(red blue green white black)
Now, address@hidden would return 5
If I then do: unset FOO[2}, the "green" element is erased and
address@hidden returns 4. However, if I do:
echo address@hidden
This is returned:
red
blue
white
black
A "null" is returned where the "green" element was.
I am trying to find a relatively simple method for compacting the array
so that it removes all empty elements. Is that possible? Does Bash have
a built in method for accomplishing that?
--
Jerry ♔
Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________
- [Help-bash] Remove an empty (null) element in an indexed array,
Jerry <=