I am new in bash and need help in this problem.
#!/bin/bash
str="This Is My Bash String"
mod="-val"
# Loop through characters of str. If index is 0, insert mod at position 0. And if the current index contains space (" "), then insert mod after the space.
echo -e str
# This should output: -valThis -valIs -valMy -valBash -valString
How can I achieve this?