Bash Scripting Tips

Knowledge | Unix/Linux Tutorials


How Can I use Backspace on the Command Prompt?

Please do the following example:
Putting or add “stty erase ^H” at the beginning of the script how it shows on the following script.

#!/bin/bash
stty erase ^H
echo -e "Hi, please type the word: c"
read word
echo "The word you entered is: $word"
echo -e "Can you please enter two words? "
read word1 word2
echo "Here is your input: $word1 $word2"
echo -e "How do you feel about bash scripting? "
#Read command now stores a reply into the default build-in variable $REPLY
read
echo "You said $REPLY, I'm glad to hear that! "
echo -e "What are your favorite colours ? "
# -a makes read command to read into an array
read -a colours
echo "My favorite colours are also ${colours[0]}, ${colours[1]} and ${colours[2]}:-)"

Related Articles