Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash assigning to new array

ss="abcdefghi"
my_array=( `echo $ss | grep -o . ` )

### without for loops ###########
declare -a NewArray=("${my_array[@]}")
echo ${NewArray[@]}

########### using a for loop #################
for i in "${my_array[@]}"
do
     new_array+=($i)
done

for i in "${new_array[@]}"
do
	echo $i
done

 
PREVIOUS NEXT
Tagged: #bash #assigning #array
ADD COMMENT
Topic
Name
3+6 =