if [ “$str1” == “$str2” ]
Take input of two string in a script and compare if both are same or not, using if statement. Create a bash script using below content and execute. It will prompt for two strings from user and check if both string are same or not.
#!/bin/bash read -p "Enter first string: " str1 read -p "Enter second string: " str2 if [ "$str1" == "$str2" ] then echo "Both strings are same" else echo "Both strings are different" fi