Reputation: 103
I need following sample bash script to behave as follows:
echo -e "Enter name: \c"
read U_IP_NAME
echo -e "You said your name is : $U_IP_NAME"
This will output to:
Enter name: Alok
You said your name is : Alok
But it I want it to be:
You said your name is : Alok
Is there a way to achieve this?
[Solved with solution given by: mouviciel]
Upvotes: 10
Views: 9815
Reputation: 67839
You want to move the cursor up one line. This is achieved with tput cuu1
:
echo -e "Enter name: \c"
read U_IP_NAME
tput cuu1
echo -e "Your said your name is : $U_IP_NAME"
More info with man tput
and man terminfo
.
Upvotes: 12