The following program shows the comparison of two strings in shell script
#!/bin/sh str1="happy" str2="happy" [ $str1 = $str2 ] echo $?
The output of the program looks like this
Amazed! The metacharacter $? tests the success and failure of the string comparison. The echo statement displays 0 for success and 1 for failure.