3 examples for read
# Read to variable with prompt read -p "Enter some text here: " variable # Test variable contain your text echo $variable
# Reads either all input until a newline or specified (-d)elimiter (or only the (-n)ext X characters) from the user to a variable or (-a)rray # in response to an optional (-p)rompt or until an optional (-t)imeout, in seconds. Input can be (-s)ilenced (so it doesn't echo to the # screen or even have backslashes (-r)emoved, so as to prevent any characters from being escaped. # This will prompt the user with "Yo dawg... etc", either record the first 3 characters of input to $xzibit or exit with a 1 after 3 seconds read -rt 3 -p "Yo dawg, I heard you liked inputting... > " -n 3 xzibit
# Reads from file descriptor, which is the first parameter, into the buffer, # which is the second paramater, x amount of bytes, which is the third # parameter. read(1, buffer, bytesToRead);