help-bash
[Top][All Lists]
Advanced

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

[Help-bash] update array index numbers?


From: adrelanos
Subject: [Help-bash] update array index numbers?
Date: Wed, 24 Jul 2013 16:03:27 +0000

Hi,

when unsetting items of an array, is it possible to update the index
numbers?

Code:

#!/bin/bash

set -x

array_length="address@hidden"

testarray=(
   "a"
   "b"
   "c"
)

array_length="address@hidden"

true "${testarray[0]}"

unset testarray[0]

array_length="address@hidden"

true "${testarray[0]}"

Result:

+ array_length=0
+ testarray=("a" "b" "c")
+ array_length=3
+ true a
+ unset 'testarray[0]'
+ array_length=2
+ true ''

Expected result, last line:

+ true b

Cheers,
adrelanos



reply via email to

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