Question
How Do I Assign User Input from a Bash Script to a Variable?
Answer
The script below will read in two variables. One will be referred to as $remoteIP and the other will be referred to as $remotePort later in the script. The "$" symbol will evaluate the variable so its value will participate in the expression (e.g., for echoing to the screen or manipulating for conditional logic) later in the script.
#!/bin/bash
echo "Enter the IP address you want to test"
read remoteIP
echo "Enter the port number you want to test"
read remotePort