Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash array and for loop

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

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

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

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





Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bash #array #loop
ADD COMMENT
Topic
Name
9+3 =