奇怪现象
来源:3-5 条件测试-字符串比较
慕粉1926212165
2021-11-01
#! /bin/bash
if [ $1 = $2 ]; then
echo "$1 == $2"
elif [ $1 > $2 ]; then
echo "$1 > $2"
elif [ $1 < $2 ]; then
echo "$1 < $2"
elif [ $1 != $2 ]; then
echo "$1 != $2"
fi
参数输入 a b 结果为 a > b
输入b a 结果却是b > a ??
写回答
1回答
-
慕粉1926212165
提问者
2021-11-01
得加上转义字符\
if [ $1 = $2 ]; then
echo "$1 == $2"
elif [ $1 \> $2 ]; then
echo "$1 > $2"
elif [ $1 \< $2 ]; then
echo "$1 < $2"
elif [ $1 != $2 ]; then
echo "$1 != $2"
fi00
相似问题