You are not logged in.
Pages: 1
Hi.
How can I separate this string:
"Leonardo"
like this:
L
e
o
n
a
r
d
o
I want to put each character in to a subscript of a array.
like this
array[0]=L
array[1]=e
array[2]=o
...
Thanks a lot.
Offline
I found the solution:
#!/usr/bin/bash
name="Leonardo"
longitud=`expr length "$name"`
for i in $(seq 0 $longitud);
do
echo ${name:$i:1}
done
Output:
leo@lein:~/Escritorio/bash$ bash shell.sh
L
e
o
n
a
r
d
o
leo@lein:~/Escritorio/bash$
Thanks.
Offline
Pages: 1