Gabriel Turqos
Active Member
- Joined
- Mar 11, 2019
- Messages
- 17
I am writing a script which requires user input. How can I prompt for user input to use in my bash script. Thanks for your offer to help. I'm very grateful.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
read command. Here's how you can use it in your script:bash # Prompt for user input echo "Please enter your name:" read name # Output the input value echo "Hello, $name! Welcome to the script."
bash # Display message and read input on the same line read -p "Enter your age: " age echo "You entered: $age"
bash # Prompt for password read -s -p "Enter your password: " password echo # For a new line after password entry # Use the password securely (e.g., not...
read command. Here's how you can use it in your script:bash # Prompt for user input echo "Please enter your name:" read name # Output the input value echo "Hello, $name! Welcome to the script."
bash # Display message and read input on the same line read -p "Enter your age: " age echo "You entered: $age"
bash # Prompt for password read -s -p "Enter your password: " password echo # For a new line after password entry # Use the password securely (e.g., not printing or processing it)
bash # Prompt for multiple inputs read -p "Enter your first name: " first_name read -p "Enter your last name: " last_name # Output the inputs echo "Hello, $first_name $last_name! Welcome to the script."
read command is versatile and allows for efficient user input handling in your script.