bash string as array
jeffangelion opened this issue · comments
Ivan Vatlin commented
The trick is using ranges
Example:
#!/usr/bin/env bash
string="123456789"
string_length=${#string}
for ((index = 0 ; index < $string_length ; index++)); do
echo $((${string:$index:1} * 10)) # we can use string as pseudo-array by setting range length to 1
done