Skip to main content
added 2 characters in body
Source Link

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

The trick is instead of storing to array[$key], store to variables array_$key.

Set:

eval "array_$key='$value'" 

Get:

value=`eval echo '$'array_$key` 

Note: Values cannot contain ' (single quote).

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

The trick is instead of storing to array[$key], store to variables array_$key.

Set:

eval "array_$key='$value'" 

Get:

value=`eval echo '$'array_$key` 

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

The trick is instead of storing to array[$key], store to variables array_$key.

Set:

eval "array_$key='$value'" 

Get:

value=`eval echo '$'array_$key` 

Note: Values cannot contain ' (single quote).

added 2 characters in body
Source Link

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

The trick is instead of storing to array[$key], store to variables array_$key.

Set:

eval "array_$key=$value""array_$key='$value'" 

Get:

value=`eval echo '$'array_$key` 

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

The trick is instead of storing to array[$key], store to variables array_$key.

Set:

eval "array_$key=$value" 

Get:

value=`eval echo '$'array_$key` 

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

The trick is instead of storing to array[$key], store to variables array_$key.

Set:

eval "array_$key='$value'" 

Get:

value=`eval echo '$'array_$key` 
added 93 characters in body
Source Link

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

The trick is instead of storing to array[$key], store to variables array_$key.

Set:

eval "array_$key=$value" 

Get:

value=`eval echo '$'array_$key` 

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

Set:

eval "array_$key=$value" 

Get:

value=`eval echo '$'array_$key` 

Shells without associative arrays

It's not that hard when keys are restricted to [0-9A-Za-z_] (numbers, letters, underscore).

The trick is instead of storing to array[$key], store to variables array_$key.

Set:

eval "array_$key=$value" 

Get:

value=`eval echo '$'array_$key` 
Source Link
Loading