Does anyone know how to do this...Can it be done?
I can extract the single characters and print then, I can substitute a string of characters in a string variable while echo'ing it...but I can't find a way to modify a string character by character so that the variable is changed...Does anyone know how to do this? Here's what I have so far...
Code:
#! /bin/sh
echo -n "enter a string->"
read mystr
echo $mystr
strlgth=${#mystr}
cntr="0"
while [ $cntr != $strlgth ]
do
echo ${mystr:$cntr:1}
cntr=`expr $cntr + 1`
done
echo ${mystr/"is"/"are"} #will replace is with are in the echo
echo $mystr #back to original here
exit 0
What I want...
mystr="this is the string"
do something here to change the third character in, say form 'i' to 'g'
so when I echo &mystr it will display 'thgs is the string'
echo $mystr -> will display thgs is the string