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

Recommended Answers

All 2 Replies

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

:) , thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.