Concept Flow - read command
Start Script
Prompt User
Wait for Input
Store Input in Variable
Use Variable
End Script
The read command waits for user input, stores it in a variable, then the script uses that input.
echo "Enter your name:" read name echo "Hello, $name!"
| Step | Action | Input/Condition | Variable State | Output |
|---|---|---|---|---|
| 1 | Print prompt | N/A | name = '' | Enter your name: |
| 2 | Wait for user input | User types 'Alice' | name = '' | |
| 3 | Store input in variable | Input 'Alice' | name = 'Alice' | |
| 4 | Print greeting | name = 'Alice' | name = 'Alice' | Hello, Alice! |
| 5 | End script | N/A | name = 'Alice' | Script ends |
| Variable | Start | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|
| name | '' (empty) | '' (waiting input) | 'Alice' | 'Alice' |
read command syntax: read variable_name Behavior: - Pauses script to get user input - Stores input in the variable - Continues script using that input Key rule: User must press Enter to finish input.