How to iterate through each letter in a string in Unix Shell
<p>I am trying to iterate through a string taken as an input through the <strong>read</strong> command. I'm trying to output the number of each letter and each letter It should then use a loop to output each letter in turn. For example, if the user enters "picasso", the output should be:</p>

<p>Letter 1: p
Letter 2: i
Letter 3: c
Letter 4: a
Letter 5: s
Letter 6: s
Letter 7: o</p>

<p>Here is my current code:</p>

<pre><code>#!/bin/bash

# Prompt a user to enter a word and output each letter in turn.


read -p "Please enter a word: " word

for i in $word
do
 echo "Letter $i: $word"
done
</code></pre>

<p>Should I be placing the input to an array? I'm still new to programming loops but I'm finding it impossible to figure out the logic.</p>

<p>Any advice? Thanks.</p>