Bash read Command
read reads one line of input and stores it in a variable.
Use -p to show a prompt, and give several names to split the line into words. Add -r so backslashes are kept as they are.
Ask for input
Save this as age.sh:
#!/bin/bash
read -p "Enter your age: " age
echo "You are $age years old."
Run it:
./age.sh
Enter your age: 25
You are 25 years old.
Split a line into words
echo "Emma Watson" | { read -r first last; echo "Last: $last"; }
Last: Watson