I've got a script that I'm reading the input from users. Here's my code:
if [ -z $volreadexists ]; then
echo -e "\tThis will overwrite the entire volume (/dev/vg01/$myhost)...are you sure?"
read REPLY
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "\t\tContinuing"
syncvolume
else
echo "Fine...skipping"
fi
fi
I'm having to use read REPLY
because read
by itself doesn't insert tabs. What I'm looking for is something similar to:
read -p "\tDoes this look OK? (n for No)" -n 1 -r
Where \t
would tab over the read prompt.
How can I add tabs to a read prompt?
UPDATE: Thanks for the great answer from @gniourf!:
read -p $'\tDoes this look OK? (n for No)' -n 1 -r
However, I found an issue. When I attempt to use a variable there it doesn't translate it:
read -p $'\tThis will overwrite the entire volume (/dev/vg01/$myhost)...are you sure? ' -n 1 -r
becomes
This will overwrite the entire volume (/dev/vg01/$myhost)...are you sure?
where I want:
This will overwrite the entire volume (/dev/vg01/server1)...are you sure?
Using doublequotes doesn't work either :(
Any ideas?