tags:

views:

48

answers:

2
+6  A: 

Here's a, hopefully quite close, translation.

var="Hello"
for (( i = 0; i < ${#var}; i++ ))
do
    echo ${var:i:1}
done

Illustrates a few bash concepts.

  • ${#var} gives the number of characters in variable ${var}
  • ${var:x:y} gives a substring of characters of ${var} starting at position x, length y
martin clayton
Thank you very much!
Michaël
+2  A: 

An alternate approach:

echo hello | sed 's/\(.\)/\1\n/g'
Steve Prentice