Variables and user Input
You now know how to execute a shell script but what about the content of the script. In bash, variables are character strings if the value of a variable only contains digits it permits arithmetic operations. There are also a number of rules regarding hard and soft quotes and where spaces can be placed. For example, there cannot be any spaces around the ‘=’ operator when defining variables. Still for the most part creating a variable is as easy as providing it with a name and value, bash does not segregate its variables by type. To query the value of your variable at a later point use $<variable_name>.
As with any script you should absolutely comment your code!!!! To add a single comment use #.
To print to your terminal at any given point use echo [option(s)] [string].
image: list of echo options taken from O’Reilly
It can be very useful to define variables after the program has been set in motion. For example, a short script to pull a number of random samples from a larger dataset could benefit from setting the number of samples or the random key without having to edit the script every time. Or setting the name of your output file as the script completes. For these examples, you could use user input. When using the read <varaible> command in your script the user will be prompted to enter some input.