linux-tutorial/codes/shell/示例脚本/逻辑控制/注意test大小写顺序和sort不同.sh

14 lines
427 B
Bash
Raw Normal View History

2019-05-10 11:17:57 +08:00
#!/bin/bash
2019-10-10 08:56:31 +08:00
2019-05-10 11:17:57 +08:00
#test命令中大小字母会被当成小于小写字符而在sort中小写字母会先出现,test使用标准的ASCII排序sort使用本地化语言设置进行排序对于英语本地化设置制定了排序顺序中小写字母出现在大写字母之前
var1=Testing
var2=testing
if [ $val1 \> $val2 ]
then
2019-10-10 08:56:31 +08:00
echo '$val1 is greater than $val2'
2019-05-10 11:17:57 +08:00
else
2019-10-10 08:56:31 +08:00
echo '$val1 is less than $val2'
2019-05-10 11:17:57 +08:00
fi