|
我按照Learning the bash shell中写的脚本, 运行不正确:
#!/bin/bash
# file name cmp.sh
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) 才能用于字符串操作.
那位dx指点一下怎么比较字符串. |
|