0

xhi, my task is to make a script, which displays the string read from console input in the form of 1 letters / line only. my code looks like this so far

read string
hossz=expr length "$string"
for i in seq 1 $hossz
do
echo expr substr $string $i 1
done

my problem is that if the string contains spaces, i only get a bunch of expr syntax errors, else its working correctly. i tried using the tr command to change the spaces into "\n" but i failed to do that too :(. also tried googleing but i couldnt find a solution, so any kind of help would be appreciated

2
Contributors
2
Replies
10
Views
3 Years
Discussion Span
Last Post by zortar
0

You know the answer already. What's the difference between the two occurences of $string?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.