Syntax
Bash Read User Input Syntax
In Bash, read user input: reads a line into a variable — read -p "Name: " name
Quick Answer
- Syntax
read -p "Name: " name
BashSyntax
Read User Input
Code example
read -p "Name: " name
Reads a line into a variable.
How to read user input in Bash
- Open your Bash file or editor.
- Copy the example, then replace its sample names and values for your code.
Bash Read User Input Syntax
Use read -p "Name: " name.
Related Syntax References
Frequently asked questions
What is the Bash syntax for read user input?
Use this pattern: read -p "Name: " name
Can I copy this Bash code example?
Yes. Use Copy code and adapt the example to your program.
Is this Bash syntax different on Mac or Windows?
No. The language syntax is the same across operating systems.
Official source · How we verify