The read Command
In this page:
The read Command
read pauses a script and waits for the user to type input, storing it into a variable. read -p "prompt" displays a prompt before waiting. It's the standard way to make an interactive script that responds to user input.
Note: Use read -s to read input silently, such as when prompting for a password.
Example: The read Command
#!/bin/bash
echo "Simulating input via echo pipe since this runs non-interactively:"
name="Guest"
echo "Hello, $name! (in an interactive terminal, 'read -p \"Name: \" name' would prompt you)"
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: