Navigating: Home » Bash » read prompts in bash script read prompts in bash script Posted on by devsrealm Last Updated on: August 16, 2020 We’ve previously taken a quick look at the builtin read command, where we use the built-in read to populate the $REPLY variable, which holds the value of read when a variable is not supplied to read, it would store whatever you type in the stdin, and we then echo it. In this guide, we would use the read to produce a prompt, and a way to supply read a variable. Fire up your console and type the following command: Copy Code Copied Use a different Browser read -p "What is Your Name: " name The syntax is using a read with the -p option, and you include the string that appear in the prompt. The last argument (name) is the variable we want to populate, so whatever input the user type is stored in this variable. This is the output of the above command, go ahead and type in a string or your name: Copy Code Copied Use a different Browser user@server:~/bin$ read -p "What is Your Name: " name What is Your Name: Mr. Devsrealmer Now, the variable name has the value you typed in memory, you can echo it as follows: Copy Code Copied Use a different Browser user@server:~/bin$ echo "You typed $name" You typed Mr. Devsrealmer Cool right! You can turn the whole thing into a simple script: Copy Code Copied Use a different Browser #!/bin/bash read -p "What is Your Name? " name echo "Your Name is $name" exit 0 Related posts:Script to Replace/substitute Multi Occurrences of A String in FilesLocal Variable, Typset and The Declare Command In Bashawk In Bash Scripting