“Shell -eq” Code-Antworten

-Eq Shell Skript

a=30
b=20
if [[ $a -eq $b ]]; then
    echo "Match"
else
    echo "No Match"
fi

Output:No Match
=================================================
a=John
b=George
if [[ $a -eq $b ]]; then
    echo "Match"
else
    echo "No Match"
fi

Output:Match
which is wrong

Conclusion:
-eq is for numerical comparison and == is for string comparison
rachelgreen

Shell -eq

-eq is for numerical comparison and == is for string comparison
a=30
b=20
if [[ $a -eq $b ]]; then
    echo "Match"
else
    echo "No Match"
fi

Output:No Match
=================================================
a=John
b=George
if [[ $a -eq $b ]]; then
    echo "Match"
else
    echo "No Match"
fi

Output:Match
which is wrong
rachelgreen

Ähnliche Antworten wie “Shell -eq”

Fragen ähnlich wie “Shell -eq”

Weitere verwandte Antworten zu “Shell -eq” auf Shell/Bash

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen