User Input Cheatsheet
User Input Cheatsheet
REQUESTING
USER INPUT
Example Script:
#!/bin/bash
echo “My Name is $1”
echo “My home directory is $2”
echo “My favourite colour is $3”
SPECIAL PARAMETERS
Special Parameter
Description Command
Parameter Value for
Line
Command Line
The read command asks for input from the user and saves
this input into a variable
read variable
OPTIONS
-t time Timeout if the user does not enter any value within
time seconds.
#!/bin/bash
#!/bin/bash
PS3="What is the day of the week?: "
select day in mon tue wed thu fri sat sun ; do
echo "The day of the week is $day"
break
done