Example #1 - destructive

Here's a script called onechar1.bash.

#!/bin/bash
echo "Please enter a word:
(leave blank and press Enter to exit)"
read someStr
if [[ $someStr == '' ]]; then
exit
fi
while test -n "$someStr"; do
c=${someStr:0:1} # Get the first character
echo "character is $c"
someStr=${someStr:1} # trim the first character
done

When I run it:

$ ./onechar1.bash
Please enter a word:
(leave blank and press Enter to exit)
My Name is Mauro
character is M
character is y
character is
character is N
character is a
character is m
character is e
character is
character is i
character is s
character is
character is M
character is a
character is u
character is r
character is o
$