If you are writing a bash script and you are fetching input from the user and you want to wait for the user input, then you can make use of the read command with a -p (prompt) option.
Let's take a look at an example script.
Example:
#!/bin/bash
read -p "Enter Your Name: " user_name
echo "Hello: $user_name"
Output:
./script.sh
Enter Your Name: Sam
Hello: Sam
You will see that the script waits for user to enter their name and only returns when enter key is pressed.

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Bash,
- Bash Hello World! Script Tutorial
- How to run bash command in background
- How to create new user account in Windows bash
- How to Compare Strings in Bash
- Bash: Allow Command to Fail without exiting Script
- Fix bash: script.sh: Permission denied Error
- Bash getopts Command Example
- How to fix bash ping command not found error
- How to add NewLine Character in Bash Script String
- How to Echo Bash Command to a File
- Bash Command to Find String in a File
- How to open new Terminal using Bash Command
- Bash How to Save Output of a Command to a Variable
- Download a SSL Certificate from a URL in Terminal
- Bash Command to Check IP Address
- Know Bash shell version command
- Bash Command To Check If File Exists
- How to run a Command in Bash Script
- How to Compare two Files in Bash Shell
- How to check if a variable is set in Bash Script or Not
- Convert String from uppercase to lowercase in Bash
- How to see Created Accessed Modified and Changed dates of a file using bash terminal command
- Bash Command To Get Current Time
- Bash command to List Files
- Fix: bash: syntax error near unexpected token
More Posts:
- How to Get the Relative Path of a file in Python Program - Python
- How to install Apache Maven on Ubuntu - Ubuntu
- Fix: hibernate.InstantiationException: No default constructor for entity: User - Java
- Disable EditText Cursor Android - Android
- Show Hide SharePoint column in List Library form with the conditional formula - SharePoint
- Fix: sudo: unable to open Read-only file system - Linux
- How to generate client id and secret to register SharePoint App with OAuth - SharePoint
- TextEdit alternative for Mac - MacOS