How do i use the read command to print a message for user input?
-
In past examples we have use echo command first and then the read command for user input. These two can be combined in the read command as follows:
-p prompt Display prompt on standard error, without a trailing new‐ line, before attempting to read any input. The prompt is displayed only if input is coming from a terminal.
The variable in the code below is
weather
.... read -p "Hello, do you think it will rain today? " weather ...
Syntax is:
read -p "msg" variable
© Lightnetics 2024