cursor positioning

Hi All,

please help me to know how to move the cursor to the desired position?

For example, in a shell script, I am displaying
echo "\t Enter your Name:"

please help me how to move cursor near the first word.

for example, if the output is as below
Enter your name:
(I want the cursor to be blinking here)

I have tried tput command. please help me..

Thankyou all in advance... :b:

jb>cat s1
echo " Enter your Name:"
read name
jb>sh s1
 Enter your Name:
myname
jb>cat s2
printf " Enter your Name:"
read name
jb>sh s2
 Enter your Name:myname
jb>

With bash :

$ read -p "Enter your text: " var
Enter your text: sssssss
$ echo $var
sssssss
$

With ksh :

$ read var?"Enter your text: "
Enter your text: sssss
$ echo $var
sssss
$

Jean-Pierre.

I'm not sure what you are trying, but here is some method howto make something.

#!/bin/ksh # or bash
# howto handle default value = user press return, nothing else
answer="y"
echo -e "Remove: (y/n): y\b\c"
read str
[ "$str" != "" ] && answer="$str"

# write something and make carriage return
echo -e "Your name\r\c"
read name

# write and remove
echo -e "Some\r\c"
sleep 2
echo -e "    \r\c"
sleep 1
echo -e "More\r\c"
sleep 1
echo
echo

#counter
i=10
echo -e "Cnt: \c"
while ((i<30))
do
     echo -e "$i\b\b\c"
     (( i+=1 ))
     sleep 1
done
echo

Using cursor something like:

clear
cat <<EOF
=========================================================
Screen test


EOF
loc0_0=$(tput cup 0 0)
bold=$(tput  smso)
boldoff=$(tput rmso)
save_loc=$(tput sc)
ret_loc=$(tput rc)

# after this init, use variable
echo "${bold}BoldText${boldoff} and not so bold"
echo -e "(Look line 0) Ask here:${save_loc}${loc0_0}LOCATION 0,0 IS HERE ***************${ret_loc}\c"
read answer
echo "${save_loc}${loc0_0}Your answer:$answer   ${ret_loc}"
echo 
echo "look line 0"

---------- Post updated at 08:49 PM ---------- Previous update was at 08:20 PM ----------

More info

man tput
man 5 terminfo