To read user input in a Bash script, you can use the read
command. Here's an example:
#!/bin/bash
echo "Enter your name: "
read name
echo "Hello, $name!"
In this example, the script prompts the user to enter their name. The read
command captures the input and assigns it to the name
variable. The script then prints a greeting using the entered name.