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.

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!