We just saw some interesting comparisons, but now things start to become more interesting because we are going to introduce some tests on strings, and this brings us a step forward in what we can do to make our scripts more reactive:
- =: This is true if the first string is equal to the second string:
#!/bin/bash echo "Hello user, please type a string and press enter:"read user_input1 echo "Now type another string and press enter:"read user_input2 if [ ${user_input1} = ${user_input2} ]thenecho "Great! The string ${user_input1} is equal to ${user_input2}"elseecho "The string ${user_input1} is not equal to ${user_input2}..."fi
And now some tests:
zarrelli:~$ ./equal.sh Hello user, please type a string and press enter:hello