Tsallaka zuwa abun ciki
Justice Tech School

Sorting and Comparing Strings

Inside [[ ]] use < and > for alphabetical order and == for equality, with quotes.

Example
[[ "apple" < "banana" ]] && echo "apple first"
[[ "a" == "a" ]] && echo "equal"
[[ "abc" != "abd" ]] && echo "different"

Result

apple first
equal
different

Exercise

Not equal strings.

[[ a  b ]]

Quiz Test

Which compares alphabetically?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.