InterviewSolution
| 1. |
How To Get Input From The Terminal For Shell Script? |
|
Answer» ‘read’ COMMAND READS in data from the terminal (using KEYBOARD). The read command takes in whatever the user types and places the TEXT into the variable you name. Example is shown below: # VI /tmp/test.sh #!/bin/bash echo ‘Please enter your name’ read name echo “My Name is $name” # ./test.sh Please enter your name LinuxTechi My Name is LinuxTechi ‘read’ command reads in data from the terminal (using keyboard). The read command takes in whatever the user types and places the text into the variable you name. Example is shown below: # vi /tmp/test.sh #!/bin/bash echo ‘Please enter your name’ read name echo “My Name is $name” # ./test.sh Please enter your name LinuxTechi My Name is LinuxTechi |
|