User Input in Bash

Ask the User for Input

# Ask the user for their name
echo Hello, who am I talking to?
read varname
echo It\'s nice to meet you $varname

More variables

# Demonstrate how read actually works
echo What cars do you like?
read car1 car2 car3
echo Your first car was: $car1
echo Your second car was: $car2
echo Your third car was: $car3

More with Read

# Ask the user for login details
read -p 'Username: ' uservar
read -sp 'Password: ' passvar
echo Thankyou $uservar we now have your login details

-p allows you to specify a prompt and -s makes the input silent