Next: , Previous: , Up: variables   [Contents][Index]


17.2 Manipulating colon variables

Function: mbfl_variable_colon_variable_to_array varname

Take varname’s value, a colon separated list of string, and store each string in the array mbfl_FIELDS, starting with a base index of zero.

Example:

VAR=a:b:c:d:e
declare -a mbfl_FIELDS

mbfl_variable_colon_variable_to_array VAR

echo ${#mbfl_FIELDS[*]}       -| 5
echo "${mbfl_FIELDS[0]}"      -| a
echo "${mbfl_FIELDS[1]}"      -| b
echo "${mbfl_FIELDS[2]}"      -| c
echo "${mbfl_FIELDS[3]}"      -| d
echo "${mbfl_FIELDS[4]}"      -| e
Function: mbfl_variable_array_to_colon_variable varname

Store each value from the array mbfl_FIELDS (with base index zero) in varname as a colon separated list of strings.

Example:

declare -a mbfl_FIELDS=(a b c d e)

mbfl_variable_array_to_colon_variable VAR
echo $VAR                       -| a:b:c:d:e
Function: mbfl_variable_colon_variable_drop_duplicate varname

Take varname’s value, a colon separated list of string, and remove duplicates. Reset varname to the result.


Next: , Previous: , Up: variables   [Contents][Index]

This document describes version 3.0.0-devel.0 of Marcos Bash Functions Library.