if [ "$1" = "$2" ]; then
echo "$1 is equal $2"
fi
if [ "$1" > "$2" ]; then
echo "$1 large than $2"
fi
if [ "$1" < "$2" ]; then
echo "$1 less than $2"
fi
输入:
$> source cmp.sh hello helo
输出:
hello large than helo
hello less than helo
好象只有(=, !=, -n, -z) 才能用于字符串操作.
#!/bin/bash
if [[ "$1" = "$2" ]]; then
echo "$1 is equal $2"
fi
if [[ "$1" > "$2" ]]; then
echo "$1 large than $2"
fi
if [[ "$1" < "$2" ]]; then
echo "$1 less than $2"
fi