Simply put a Shell Script is a program that is run by a UNIXLinux shell. It is a file that contains a series of commands which are executed sequentially as if they were entered on the command line interface CLI or terminal.
In this quick tutorial on Shell Scripting we will write a simple program to toss a coin. Basically the output of our program should be either HEADS or TAILS of course randomly.
To start with the first line of a shell script should indicate which interpretershell is to be used to execute the script. In this tutorial we will be using binbash and it will be denoted as binbash which is called a shebang.
Next we will be using an internal Bash function 8211 a shell variable named RANDOM. It returns a random actually pseudorandom integer in the range 0-32767. We will use this variable to get 2 random values either 0 for HEADS or 1 for TAILS. This will be done via a simple arithmetic operation in shell using Modulus operator returns remainder RANDOM2 and this will be stored in a result variable. So the second line of our program becomes ResultRANDOM2 Note that there should be no space around assignment operator while assigning value to a variable in shell scripts.