EN
Bash - compare string variable to another string
0
points
In this article, we would like to show you how to compare string variable to another string in Bash.
Practical example
In this example, we use ==
operator to compare two strings inside if
statement.
script.sh
file:
#!/bin/bash
string='value'
if [ "$string" == "value" ]; then
echo "The strings are equal."
fi
Run in command line:
./script.sh
Output:
The strings are equal.