I am trying to split letters from a word and print them in new line using the following method. But I am not able to assign values to the variable. Correct me if I am missing any fundamental rule here.
stringOneLength=$(echo `expr length $1`)
echo $stringOneLength
stringTwoLength=$(echo `expr length $2`)
echo $stringTwoLength
for ((i=1; i<=$stringTwoLength; i++)) ;
do
x$i=$(echo "$1" | sed 's/\(.\{1\}\)/\1 /g' | sed 's/\(.\{1\}\)/\1 /g' |awk '{print $i}')
echo x$i
done
Getting following error:
sh FileName one two
3
3
samp: line 13: x1=o: command not found
x1
samp: line 13: x2=o: command not found
x2
samp: line 13: x3=o: command not found
x3
What is wrong with my approach and how can I fix my variable assignment?