#!/bin/bash
## manipulate strings.
## author: Xiaoxu Guan at LSU HPC.
## Jan 30, 2016

echo

my_string=0123456789_abcxyz_ABCXYZ

echo "my_string=$my_string"

echo "echo \${#my_string[@]} = "  ${#my_string[@]}  # number of elements in the array.
echo "echo \${my_string[*]} = "   ${my_string[*]}   # print out all elements.
echo "echo \${my_string[@]} = "   ${my_string[@]}   # the same as the above.

echo "echo \${#my_string[0]} = "   ${#my_string[0]}  # length of the array element in terms of characters.
echo "echo \${#my_string[2]} = "   ${#my_string[2]}  # the same as the above.


echo "echo \${my_string[@]:4:8} = "   ${my_string[@]:4:8}

new_string=${my_string[@]:4:8}bcdefg

echo "echo \${my_string[@]:4:8}bcdefg = " $new_string

echo
